feat(admin): operational stats — hourly trends, recurrence, dashboard

Extend GET /v1/stats/trend with granularity=hour (UTC buckets) and granularity=day
response envelope. Enrich GET /v1/stats/summary per-project totals and critical
counts. Add GET /v1/stats/recurrence for top incidents by occurrence volume in
a sliding window. Add index on er_incident_occurrences(occurred_at) for range
queries. Wire admin dashboard to summary, 24h/14d trends, and recurrence table.
Document contract in docs/ADMIN_STATS_API.md.

Paperclip-Agent: Pedro Alves (urlKey pedro-alves; id d706f4e6-5d05-4cec-b6e8-f8fb1f203aae)
Paperclip-Issue: BIT-728
Paperclip-Run: 948904bb-20d7-4d29-9cd7-4c22544f7570
Made-with: Cursor
This commit is contained in:
David Santos committed 2026-04-02 11:00:51 +00:00
1 parent c4e0b03ed8
commit de68f68103
6 files changed
+643 -23

No files matched your search

@@ -0,0 +1,5 @@
BEGIN;
DROP INDEX er_incident_occurrences_occurred_at_idx ON er_incident_occurrences;
COMMIT;
@@ -0,0 +1,7 @@
BEGIN;
-- Time-range aggregations (recurrence, global trends without project filter)
CREATE INDEX IF NOT EXISTS er_incident_occurrences_occurred_at_idx
ON er_incident_occurrences (occurred_at DESC);
COMMIT;