From 3e738b18d4a84bbcb9a412505f8096149148a269 Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Sun, 15 Mar 2026 00:33:23 +0800 Subject: [PATCH] Scope starred events to upcoming_days window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starred events query had no upper date bound — a starred recurring event would fill all 5 countdown slots with successive occurrences beyond the user's configured range. Now capped to upcoming_cutoff_dt. Co-Authored-By: Claude Opus 4.6 --- backend/app/routers/dashboard.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/app/routers/dashboard.py b/backend/app/routers/dashboard.py index 3e6f076..e69a7e6 100644 --- a/backend/app/routers/dashboard.py +++ b/backend/app/routers/dashboard.py @@ -95,11 +95,13 @@ async def get_dashboard( total_todos = todo_row.total total_incomplete_todos = todo_row.incomplete - # Starred events (upcoming, ordered by date, scoped to user's calendars) + # Starred events (within upcoming_days window, ordered by date, scoped to user's calendars) + upcoming_cutoff_dt = datetime.combine(upcoming_cutoff, datetime.max.time()) starred_query = select(CalendarEvent).where( CalendarEvent.calendar_id.in_(user_calendar_ids), CalendarEvent.is_starred == True, CalendarEvent.start_datetime > today_start, + CalendarEvent.start_datetime <= upcoming_cutoff_dt, _not_parent_template, ).order_by(CalendarEvent.start_datetime.asc()).limit(5) starred_result = await db.execute(starred_query)