From 82c9aeccb57af082d1e8786759787414fa933ac4 Mon Sep 17 00:00:00 2001 From: Peter Vacho Date: Thu, 2 Jan 2025 14:45:53 +0100 Subject: [PATCH] Fix getting invited events with range limits --- src/api/events.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/events.py b/src/api/events.py index dcd5a4d..9d5b8e6 100644 --- a/src/api/events.py +++ b/src/api/events.py @@ -217,6 +217,7 @@ async def get_user_events( if end_to is not None: query = query.find(expr(Event.end_time) <= end_to) + # We can't set this earlier as the other find calls would reset it query = query.find(fetch_links=True) events = await query.to_list() @@ -249,7 +250,7 @@ async def get_user_invited_events( ) # Initial query (all events the user is attending) - query = Event.find(expr(Event.attendees).id == user_id, fetch_links=True) + query = Event.find(expr(Event.attendees).id == user_id) # Filter by date-time if start_from is not None: @@ -261,6 +262,9 @@ async def get_user_invited_events( if end_to is not None: query = query.find(expr(Event.end_time) <= end_to) + # We can't set this earlier as the other find calls would reset it + query = query.find(fetch_links=True) + events = await query.to_list() return [EventData.from_event(event) for event in events]