Scope starred events to upcoming_days window

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 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-15 00:33:23 +08:00
parent e630832e76
commit 3e738b18d4

View File

@ -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)