mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
perf(medications-intake): consume compliance rollup tier
Swaps `/api/medications/intake?scope=compliance` onto the rollup reader behind a coverage probe — a user with intake events but no rollup rows still gets a correct response from the legacy live aggregator and triggers the boot backfill in the background so the next request lands on the rollup path. Every write site that mutates `MedicationIntakeEvent` (POST + PUT + DELETE + per-medication import, bulk batch, telegram callbacks, external API ingest, admin restore) now fires `recomputeMedicationComplianceForEvent` for the affected user-day. Bulk + import collapse the per-row hooks to one recompute per distinct `(medicationId, dayKey)` so a 500-row ingest still costs a bounded fold. Purge wipes the rollup partition alongside the intake-event deleteMany. Eliminates the 3.2 s cold mount the v1.4.38 perf analysis attributed to the unbounded event findMany.
This commit is contained in:
1 parent
83d96a9817
commit
227eb69b63
9 files changed
+246
-4
No files matched your search
@@ -44,6 +44,10 @@ import {
|
||||
type BackupSummary,
|
||||
} from "@/lib/validations/backup";
|
||||
import { recomputeUserMoodRollups } from "@/lib/mood/rollups";
|
||||
import {
|
||||
recomputeUserMedicationCompliance,
|
||||
MEDICATION_COMPLIANCE_BACKFILL_DAYS,
|
||||
} from "@/lib/medications/compliance-rollups";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
Reference in new issue
Block a user