mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 15:02:04 +00:00
perf: collapse the medication compliance hot path and the dashboard fan-out
The medication list fired one compliance request per card every 30 seconds, and each request scanned the medication's full intake history and expanded the recurrence calendar five to six times. The endpoint now mints bands once per request, serves the sub-windows from that single ledger, bounds the event read to a year of selected columns and sits behind a write-invalidated 15-minute server cache; the cards poll at five minutes. The dashboard drops two redundant checklist queries by reading counts from the snapshot, the BMI chart derives from the weight series instead of refetching it, the detail page no longer serialises behind the auth probe and seeds its query from the list row. Expensive analytics reads gain a shared per-user rate limit, and the service worker stops serving cross-version shells, enables navigation preload and trims caches in one pass.
This commit is contained in:
1 parent
41ba4c6c17
commit
298e4c34b4
24 files changed
+1483
-319
No files matched your search
Vendored
+16
@@ -393,6 +393,22 @@ export const caches = {
|
||||
maxEntries: 1000,
|
||||
ttlMs: 900_000,
|
||||
}),
|
||||
/**
|
||||
* v1.15.20 — per-medication compliance payload
|
||||
* (`GET /api/medications/[id]/compliance`). The medications list fans
|
||||
* the endpoint out once per card, and each cold build runs the full
|
||||
* band-expansion pass — so the warm path has to live server-side.
|
||||
* Keyed `${userId}|${medicationId}|compliance`; every intake /
|
||||
* medication write flushes the `${userId}|` prefix via
|
||||
* `invalidateUserMedications`, so the 15-minute TTL only bounds
|
||||
* wall-clock drift (a dose flipping overdue), never user-action
|
||||
* staleness. Sized for a few hundred users × a handful of meds.
|
||||
*/
|
||||
medicationCompliance: new ServerCache<unknown>({
|
||||
name: "medicationCompliance",
|
||||
maxEntries: 2000,
|
||||
ttlMs: 900_000,
|
||||
}),
|
||||
moodAnalytics: new ServerCache<unknown>({
|
||||
name: "moodAnalytics",
|
||||
maxEntries: 1000,
|
||||
|
||||
Reference in new issue
Block a user