From a524678c3ba5e73f0e5496f028a40ca2995f5d5a Mon Sep 17 00:00:00 2001
From: gregor <gregor.schulz@holi.social>
Date: Tue, 18 Mar 2025 19:08:20 +0100
Subject: [PATCH] add remoteOnly request parameter

---
 app/fetch_events.ts | 7 ++++++-
 app/server.ts       | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/app/fetch_events.ts b/app/fetch_events.ts
index 706e42e..f7599f6 100644
--- a/app/fetch_events.ts
+++ b/app/fetch_events.ts
@@ -60,7 +60,7 @@ const toHoliEvent = (event: AppApiEvent): HoliEvent => {
 }
 
 const buildJasdAppApiUrl = (
-  { limit, offset, location }: FetchEventsInput,
+  { limit, offset, location, remoteOnly }: FetchEventsInput,
 ): URL => {
   const url = new URL(`${APP_API_BASE_URL}/search`)
   url.searchParams.append('page', offset.toString())
@@ -71,6 +71,10 @@ const buildJasdAppApiUrl = (
   url.searchParams.append('includeExpiredActivities', 'false')
   url.searchParams.append('permanent', 'false')
 
+  if (remoteOnly) {
+    url.searchParams.append('online', 'true')
+  }
+
   if (location) {
     url.searchParams.append('location', location)
   }
@@ -125,6 +129,7 @@ export type FetchEventsInput = {
   limit: number
   offset: number
   location?: string
+  remoteOnly?: boolean
 }
 
 export const fetchEvents = async (
diff --git a/app/server.ts b/app/server.ts
index 8704cc2..68e4090 100644
--- a/app/server.ts
+++ b/app/server.ts
@@ -40,7 +40,7 @@ const eventsTypeDefs = `
     
     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): EventsResponse!
+      events(offset: Int = 0, limit: Int = 5, location: String, remoteOnly: Boolean): EventsResponse!
       event(id: String!): EventResponse!
     }
 `
@@ -49,6 +49,7 @@ export type EventsRequest = {
   limit?: number
   offset?: number
   location?: string
+  remoteOnly?: boolean
 }
 
 export type EventRequest = {
@@ -61,6 +62,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput =>
     limit: request.limit ?? 5,
     offset: request.offset ?? 0,
     location: request.location,
+    remoteOnly: request.remoteOnly,
   }
 }
 
-- 
GitLab