KPI Refresh Scheduler
Component Detail
Infrastructure
low complexity
backend
1
Dependencies
0
Dependents
0
Entities
0
Integrations
Description
Vercel Cron Job or background function that periodically triggers a refresh of the kpi_summaries materialized view. Ensures dashboard data remains near-current without requiring expensive real-time aggregation on every page load. Configurable refresh interval (default: every 5 minutes).
kpi-refresh-scheduler
Sources & reasoning
Materialized views require a refresh mechanism to stay current. A dedicated cron job decouples the refresh cycle from user requests, satisfying the near-real-time requirement in the implementation notes without blocking dashboard reads.
-
docs/source/likeperson.md · line 186Coordinator and organization-level dashboards and KPIs
-
docs/source/likeperson.md · line 317Aktivitetsoversikt og grunnleggende statistikk
-
docs/source/likeperson.md · line 231Admin Web Portal: `admin-dashboard`, `admin-user-management`, `admin-organization`, `admin-security`
Responsibilities
- Trigger REFRESH MATERIALIZED VIEW kpi_summaries on schedule
- Log refresh duration and last-refresh timestamp for observability
- Emit an alert if refresh fails or exceeds timeout threshold
Interfaces
POST /api/cron/refresh-kpis (Vercel Cron)
triggerRefresh(): Promise<void>