mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
refactor(medications): drop the compliance rollup table that nothing reads
medication_compliance_rollups lost its last reader when compliance moved to the schedule-anchored computation, yet every dose write still upserted it, a boot backfill refolded it, and the wipe and backup plans carried it. The per-dose hook keeps the one derived row that still hangs off a dose day, the supplement nutrients, under dose-day-refresh. The pending-row mints (today projection, reminder) no longer call it, since an untaken dose adds no nutrients. The import job finishes without its per-day recompute phase; its progress keeps touchedDays and rollupProcessed on the wire, inert and documented as deprecated. The backfill queue is retired on boot and migration 0414 drops the table under a bounded lock wait.
This commit is contained in:
1 parent
b90c82cba3
commit
41de0ca126
71 files changed
+314
-2027
No files matched your search
@@ -9544,10 +9544,9 @@ paths:
|
||||
defend against a poisoned column. Audit-logged with the old and new zone.
|
||||
|
||||
|
||||
A change is not only a display preference. The medication-compliance rollup keys its rows by the LOCAL day a
|
||||
dose fell on, minted under whatever zone was in force at write time, so moving the zone re-buckets that history
|
||||
and the stored keys go stale — and the coverage probe compares counts rather than keys, so it cannot notice. The
|
||||
route therefore enqueues a re-fold of the trailing window whenever the zone actually changes. Best-effort and
|
||||
A change is not only a display preference. The supplement nutrient rows key on the LOCAL day a dose fell on,
|
||||
minted under whatever zone was in force at write time, so moving the zone re-buckets them. The route therefore
|
||||
enqueues a recompute of the account's supplement nutrients whenever the zone actually changes. Best-effort and
|
||||
de-duplicated, so rapid re-picks collapse into one.
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -52993,12 +52992,15 @@ components:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: Local calendar days (YYYY-MM-DD) touched so far, driving the chunked rollup recompute behind the write.
|
||||
description: "Deprecated and inert: always `[]` on a job admitted from v1.43.8, when the per-day compliance rollup it
|
||||
drove was removed. A job admitted earlier keeps the days it recorded. Kept for clients that decode it; do
|
||||
not read it."
|
||||
rollupProcessed:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 9007199254740991
|
||||
description: Of `touchedDays`, how many have had their rollup recomputed.
|
||||
description: "Deprecated and inert: always `0` on a job admitted from v1.43.8. Kept for clients that decode it; do not
|
||||
read it."
|
||||
required:
|
||||
- processed
|
||||
- total
|
||||
|
||||
@@ -33,9 +33,9 @@ metadata (`medication_schedules`):
|
||||
- After upgrading to v1.15.19+, when a user reports a compliance rate above
|
||||
100 %, duplicate entries in the medication history, or a dose shown as
|
||||
taken days away from its slot.
|
||||
- The compliance rollup counts DISTINCT slots since v1.15.19, so the
|
||||
percentages self-correct on recompute even without running this script.
|
||||
Running it additionally clears the phantom rows from the history view.
|
||||
- Compliance counts DISTINCT slots since v1.15.19, so the percentages are
|
||||
right even without running this script. Running it additionally clears
|
||||
the phantom rows from the history view.
|
||||
- The `intake-slot-dedup` worker already collapses canonical-slot
|
||||
duplicates at boot and on a daily cron; this script is the manual,
|
||||
immediately-observable fallback and the only path that surfaces the
|
||||
@@ -104,13 +104,9 @@ healthlog-tsx scripts/repair-intake-anomalies.ts --fix
|
||||
as the duplicate losers). A medication without any derivable anchor
|
||||
(PRN-only / unscheduled) is skipped — there is nothing to compare
|
||||
against.
|
||||
- **Affected compliance rollups are recomputed** for every touched
|
||||
`(user, medication, day)`. The script executes the same DISTINCT-slot
|
||||
aggregation SQL the shared helper runs (a verbatim twin of
|
||||
`recomputeMedicationComplianceForDay` in
|
||||
`src/lib/rollups/medication-compliance-rollups.ts` — kept inline so
|
||||
the script needs no app imports), so the scheduled/taken counts and
|
||||
the rate self-correct immediately.
|
||||
- **No separate recompute is needed.** Every compliance reader folds the
|
||||
rows that share one slot, so the scheduled/taken counts and the rate are
|
||||
right as soon as the duplicates are tombstoned.
|
||||
|
||||
The script is idempotent: a second `--fix` run finds zero duplicate groups
|
||||
and changes nothing. Exit code is 0 on success (including a clean
|
||||
|
||||
Reference in new issue
Block a user