🛑 The Problem
Currently, we calculate the complex mathematical Health Score (variance, standard deviations, time decay) on-the-fly when the user loads the dashboard. This is incredibly slow and CPU intensive. We need to separate the Write operations (ingesting commits) from the Read operations (viewing the score) using the CQRS pattern.
💡 The Solution
Build an offline Projection Engine. When commits are ingested, a background worker should calculate the score once and save it to a flat, highly-optimized read table.
🛠️ Implementation Details
- Create a new Inngest event:
analytics.calculate_health.
- Create a worker that listens for this event.
- When triggered, the worker fetches all necessary raw data from the DB, runs the heavy math algorithms, and generates the final JSON payload.
- Upsert this payload into the
health_snapshots table.
- The frontend Next.js app should ONLY ever read from
health_snapshots with a simple SELECT * WHERE repo_id = X limit 1.
✅ Acceptance Criteria
Ready to tackle this? Comment .take below to get automatically assigned!
🛑 The Problem
Currently, we calculate the complex mathematical Health Score (variance, standard deviations, time decay) on-the-fly when the user loads the dashboard. This is incredibly slow and CPU intensive. We need to separate the Write operations (ingesting commits) from the Read operations (viewing the score) using the CQRS pattern.
💡 The Solution
Build an offline Projection Engine. When commits are ingested, a background worker should calculate the score once and save it to a flat, highly-optimized read table.
🛠️ Implementation Details
analytics.calculate_health.health_snapshotstable.health_snapshotswith a simpleSELECT * WHERE repo_id = X limit 1.✅ Acceptance Criteria
Ready to tackle this? Comment
.takebelow to get automatically assigned!