mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
feat(medications): schedules remember their history
Editing a schedule's times no longer rewrites the past. Each material change archives the outgoing cadence as a dated revision, and every band consumer — history, compliance, write attribution, the auto-miss cutoff — mints past periods from the schedule that was valid at the time, so a dose era taken at its then-correct times stays on time forever. The repair script can infer historical eras from consistent old anchors behind an explicit flag. The welcome tour scrolls its target into view, flips above it when space below runs out and falls back to a centred sheet on any viewport, so no step can strand its buttons below the fold. The avatar menu drops the about entry — that lives in settings.
This commit is contained in:
1 parent
5bfafa6f51
commit
bd78cd7f7a
26 files changed
+1806
-223
No files matched your search
@@ -115,3 +115,32 @@ pnpm dlx --package pg --package tsx tsx scripts/repair-intake-anomalies.ts --fix
|
||||
The script is idempotent: a second `--fix` run finds zero duplicate groups
|
||||
and changes nothing. Exit code is 0 on success (including a clean
|
||||
zero-findings run), non-zero on bad arguments or a fatal error.
|
||||
|
||||
## Era backfill (`--backfill-eras`, v1.16.3)
|
||||
|
||||
Schedule edits made before v1.16.3 replaced the schedule rows without
|
||||
archiving the old state, so history reads past days against the current
|
||||
times. Section 5 of the script infers the lost era from the recorded
|
||||
slot anchors:
|
||||
|
||||
- A medication qualifies when its anchor-shaped rows (user-tz `HH:mm` on
|
||||
a 5-minute grid) deviate from the **current** `times_of_day` for at
|
||||
least 7 consecutive recorded days before the current times first
|
||||
appear, and it has **no** existing `medication_schedule_revisions`
|
||||
row (re-runs are idempotent).
|
||||
- The proposal is one revision row: `valid_from` = the first deviating
|
||||
row's instant, `valid_until` = local midnight of the first day on the
|
||||
current times, payload = one `FREQ=DAILY` schedule carrying the
|
||||
observed old times.
|
||||
- A `starts_on` that postdates the first recorded row is flagged and
|
||||
pulled back to that row's instant.
|
||||
|
||||
The default run only **reports** the proposals. Apply them explicitly:
|
||||
|
||||
```bash
|
||||
pnpm dlx --package pg --package tsx tsx scripts/repair-intake-anomalies.ts --backfill-eras
|
||||
```
|
||||
|
||||
Review the dry-run table first — the inference is a heuristic. A wrongly
|
||||
created revision can be deleted from `medication_schedule_revisions`
|
||||
without side effects (the read paths fall back to live-only minting).
|
||||
Reference in new issue
Block a user