From 092aec3c19cb4d13cc4dac4fc5552dc80dacf15c Mon Sep 17 00:00:00 2001
From: gregor <gregor.schulz@holi.social>
Date: Fri, 21 Mar 2025 14:18:33 +0100
Subject: [PATCH] adapt schmea and inputs to geolocation id

---
 app/fetch_events.ts | 14 ++++++++++----
 app/server.ts       |  6 +++---
 deno.lock           | 25 ++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/app/fetch_events.ts b/app/fetch_events.ts
index a0b9855..0a657b2 100644
--- a/app/fetch_events.ts
+++ b/app/fetch_events.ts
@@ -59,8 +59,11 @@ const toHoliEvent = (event: AppApiEvent): HoliEvent => {
   }
 }
 
-const buildJasdAppApiUrl = (
-  { limit, offset, location, localOnly }: FetchEventsInput,
+const buildJasdAppApiQueryUrl = (
+  limit: number,
+  offset: number,
+  localOnly: boolean,
+  location?: string,
 ): URL => {
   const url = new URL(`${APP_API_BASE_URL}/search`)
   url.searchParams.append('page', offset.toString())
@@ -131,13 +134,16 @@ export type FetchEventsInput = {
   limit: number
   offset: number
   localOnly: boolean
-  location?: string
+  geolocationId?: string
 }
 
 export const fetchEvents = async (
   input: FetchEventsInput,
 ): Promise<HoliEventsResponse> => {
-  const url = buildJasdAppApiUrl(input)
+  //todo gregor: connect to geo api gateway
+  const city = undefined
+
+  const url = buildJasdAppApiQueryUrl(input.limit, input.offset, input.localOnly, city)
   const fetchResult = await fetchEventsPage(url)
 
   return {
diff --git a/app/server.ts b/app/server.ts
index 56c95ea..52a8fe8 100644
--- a/app/server.ts
+++ b/app/server.ts
@@ -41,7 +41,7 @@ const SCHEMA = `
     
     type Query {
       # uses offset-based pagination as described in https://www.apollographql.com/docs/react/pagination/offset-based
-      events(offset: Int = 0, limit: Int = 5, location: String, localOnly: Boolean): EventsResponse!
+      events(offset: Int = 0, limit: Int = 5, geolocationId: ID, localOnly: Boolean): EventsResponse!
       event(id: String!): EventResponse!
     }
 `
@@ -49,7 +49,7 @@ const SCHEMA = `
 export type EventsRequest = {
   limit?: number
   offset?: number
-  location?: string
+  geolocationId?: string
   localOnly?: boolean
 }
 
@@ -68,7 +68,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput =>
   return {
     limit: limit,
     offset: request.offset ?? 0,
-    location: request.location,
+    geolocationId: request.geolocationId,
     localOnly: request.localOnly ?? false,
   }
 }
diff --git a/deno.lock b/deno.lock
index 43e4717..4da3ff6 100644
--- a/deno.lock
+++ b/deno.lock
@@ -3,7 +3,11 @@
   "specifiers": {
     "jsr:@std/assert@^1.0.10": "1.0.11",
     "jsr:@std/assert@^1.0.11": "1.0.11",
+    "jsr:@std/async@^1.0.9": "1.0.11",
+    "jsr:@std/data-structures@^1.0.6": "1.0.6",
+    "jsr:@std/fs@^1.0.9": "1.0.14",
     "jsr:@std/internal@^1.0.5": "1.0.5",
+    "jsr:@std/path@^1.0.8": "1.0.8",
     "jsr:@std/testing@^1.0.9": "1.0.9",
     "npm:graphql-yoga@5.13.2": "5.13.2_graphql@16.10.0",
     "npm:graphql@16.10.0": "16.10.0"
@@ -15,14 +19,33 @@
         "jsr:@std/internal"
       ]
     },
+    "@std/async@1.0.11": {
+      "integrity": "eee0d3405275506638a9c8efaa849cf0d35873120c69b7caa1309c9a9e5b6f85"
+    },
+    "@std/data-structures@1.0.6": {
+      "integrity": "76a7fd8080c66604c0496220a791860492ab21a04a63a969c0b9a0609bbbb760"
+    },
+    "@std/fs@1.0.14": {
+      "integrity": "1e84bf0b95fe08f41f1f4aea9717bbf29f45408a56ce073b0114474ce1c9fccf",
+      "dependencies": [
+        "jsr:@std/path"
+      ]
+    },
     "@std/internal@1.0.5": {
       "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
     },
+    "@std/path@1.0.8": {
+      "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
+    },
     "@std/testing@1.0.9": {
       "integrity": "9bdd4ac07cb13e7594ac30e90f6ceef7254ac83a9aeaa089be0008f33aab5cd4",
       "dependencies": [
         "jsr:@std/assert@^1.0.10",
-        "jsr:@std/internal"
+        "jsr:@std/async",
+        "jsr:@std/data-structures",
+        "jsr:@std/fs",
+        "jsr:@std/internal",
+        "jsr:@std/path"
       ]
     }
   },
-- 
GitLab