From c72c28f5dcb491f3df195bbb9300eff30029193a Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Thu, 24 Sep 2026 01:15:23 -0400 Subject: [PATCH] frontend: incident date filter matched nothing Incident started_at is an isoformat() string (incident_correlator.py, routers/incidents.py), not a Firestore timestamp like calls. The range bounds were Dates, which Firestore compares by type, so any date range returned zero incidents. Bounds are now UTC ISO strings in the same "+00:00" shape, which order lexicographically by time. Co-Authored-By: Claude Opus 5.5 --- drb-frontend/lib/useIncidents.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drb-frontend/lib/useIncidents.ts b/drb-frontend/lib/useIncidents.ts index 5619b61..62d8602 100644 --- a/drb-frontend/lib/useIncidents.ts +++ b/drb-frontend/lib/useIncidents.ts @@ -42,11 +42,17 @@ export function useIncidents(limitCount = 100, dateFrom?: Date, dateTo?: Date) { } // A range on the ordered field rides the existing org_id/started_at index. + // Incident started_at is stored as a Python isoformat() STRING + // ("2026-09-20T12:00:00.123456+00:00", incident_correlator.py), not a + // Firestore timestamp — unlike calls. A Date bound compares by type and + // matches nothing, so the bounds go in as UTC ISO strings in the same + // shape, which then compare lexicographically in time order. + const isoBound = (ms: number) => new Date(ms).toISOString().replace("Z", "+00:00"); const q = query( collection(db, "incidents"), where("org_id", "==", orgId), - ...(dateFromMs != null ? [where("started_at", ">=", new Date(dateFromMs))] : []), - ...(dateToMs != null ? [where("started_at", "<=", new Date(dateToMs))] : []), + ...(dateFromMs != null ? [where("started_at", ">=", isoBound(dateFromMs))] : []), + ...(dateToMs != null ? [where("started_at", "<=", isoBound(dateToMs))] : []), orderBy("started_at", "desc"), limit(limitCount) );