Fix dashboard endpoint returning past todos and reminders

- Add lower-bound filter (>= today) for upcoming_todos in /dashboard
- Add lower-bound filter (>= today_start) for active_reminders
- Prevents DayBriefing summary from referencing stale items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-02-21 11:58:36 +08:00
parent c2c4446ea6
commit 97242ee928

View File

@ -35,19 +35,21 @@ async def get_dashboard(
events_result = await db.execute(events_query) events_result = await db.execute(events_query)
todays_events = events_result.scalars().all() todays_events = events_result.scalars().all()
# Upcoming todos (not completed, with due date within upcoming_days) # Upcoming todos (not completed, with due date from today through upcoming_days)
todos_query = select(Todo).where( todos_query = select(Todo).where(
Todo.completed == False, Todo.completed == False,
Todo.due_date.isnot(None), Todo.due_date.isnot(None),
Todo.due_date >= today,
Todo.due_date <= upcoming_cutoff Todo.due_date <= upcoming_cutoff
).order_by(Todo.due_date.asc()) ).order_by(Todo.due_date.asc())
todos_result = await db.execute(todos_query) todos_result = await db.execute(todos_query)
upcoming_todos = todos_result.scalars().all() upcoming_todos = todos_result.scalars().all()
# Active reminders (not dismissed, is_active = true) # Active reminders (not dismissed, is_active = true, from today onward)
reminders_query = select(Reminder).where( reminders_query = select(Reminder).where(
Reminder.is_active == True, Reminder.is_active == True,
Reminder.is_dismissed == False Reminder.is_dismissed == False,
Reminder.remind_at >= today_start
).order_by(Reminder.remind_at.asc()) ).order_by(Reminder.remind_at.asc())
reminders_result = await db.execute(reminders_query) reminders_result = await db.execute(reminders_query)
active_reminders = reminders_result.scalars().all() active_reminders = reminders_result.scalars().all()