ID Suchen

This commit is contained in:
Moritz Utcke
2025-03-23 19:21:14 -03:00
parent 302ae192ac
commit 83b618b59d
2 changed files with 19 additions and 15 deletions

View File

@@ -10,7 +10,7 @@ const caller = createCaller(Astro)
const params = Astro.params; const params = Astro.params;
const page = Number(params.page) const page = Number(params.page)
const id = parseInt(Astro.url.searchParams.get("id") || "") || null const id = Astro.url.searchParams.get("id");
const user = await caller.user.self.GET.fetch(undefined, { const user = await caller.user.self.GET.fetch(undefined, {
@@ -43,7 +43,7 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
verbrauchsausweise_gewerbe: { verbrauchsausweise_gewerbe: {
some: { some: {
alte_ausweis_id: id alte_ausweis_id: parseInt(id)
} }
}, },
} }
@@ -54,7 +54,7 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
verbrauchsausweise_wohnen: { verbrauchsausweise_wohnen: {
some: { some: {
alte_ausweis_id: id alte_ausweis_id: parseInt(id)
} }
}, },
} }
@@ -65,7 +65,7 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
bedarfsausweise_wohnen: { bedarfsausweise_wohnen: {
some: { some: {
alte_ausweis_id: id alte_ausweis_id: parseInt(id)
} }
}, },
} }
@@ -76,7 +76,9 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
verbrauchsausweise_gewerbe: { verbrauchsausweise_gewerbe: {
some: { some: {
id: id uid: {
startsWith: `vag-${id}`
}
} }
}, },
} }
@@ -87,7 +89,9 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
verbrauchsausweise_wohnen: { verbrauchsausweise_wohnen: {
some: { some: {
id: id uid: {
startsWith: `vaw-${id}`
}
} }
}, },
} }
@@ -98,7 +102,9 @@ const objekte = await prisma.objekt.findMany({
some: { some: {
bedarfsausweise_wohnen: { bedarfsausweise_wohnen: {
some: { some: {
id: id uid: {
startsWith: `baw-${id}`
}
} }
}, },
} }

View File

@@ -1,11 +1,9 @@
function murmurHash36(str: string) {
let h = 0xdeadbeef;
for (let i = 0; i < str.length; i++) {
h = Math.imul(h ^ str.charCodeAt(i), 2654435761);
}
return (h >>> 0).toString(36).toUpperCase().slice(0, 6);
}
/**
* Kürzt eine UUID auf 6 Zeichen indem es die ersten 6 Zeichen dieser UUID benutzt.
* @param uid Die UID
* @returns Eine gekürzte Version der UID
*/
export function shortenUID(uid: string) { export function shortenUID(uid: string) {
return murmurHash36(uid); return uid.split("-")[1].slice(0, 6).toUpperCase();
} }