diff --git a/web/app.py b/web/app.py index eb714bf..175aa7e 100644 --- a/web/app.py +++ b/web/app.py @@ -1148,6 +1148,7 @@ async def api_stale_cases(days: int = 3): EXTRACT(DAY FROM (now() - updated_at))::int AS days_stale FROM cases WHERE status NOT IN ('final', 'new', 'exported') + AND archived_at IS NULL AND updated_at < now() - make_interval(days => $1) ORDER BY updated_at ASC -- oldest stale first (longest overdue = highest priority) """,