fix(medications): keep a recorded miss from before the medication's creation

The history view treated every auto-miss anchored before the medication's
creation as the today projector's placeholder and dropped it. That is true
only on the creation day. History that arrives from before the creation, a
restore of an older file for one, can carry real misses, and those vanished
from the history and the rates.

The creation stays the boundary of expected doses: an earlier one, the
first recorded dose or the course start date, would read every day between
it and the creation that no row names as missed, and an import carries
takes and skips only, so those misses would be invented. Before it, every
recorded take, skip and miss claims its slot. Only rows that record nothing
are dropped: a pending row, and an auto-miss within the day before the
creation, which is where the projector's placeholders sit.

Refs #1028
This commit is contained in:
Marc-André Bombeck committed 2026-09-24 19:53:42 +02:00
1 parent f028d9c55b
commit eafef5adeb
4 files changed
+107 -18

No files matched your search

+6 -4
View File
@@ -5985,13 +5985,15 @@ paths:
schema:
description: Window start (inclusive). Defaults to 90 days before `to`; clamped to a 366-day span floor. Recorded doses
are returned from this instant. A slot from before the medication's `createdAt` appears only when a
recorded dose (a take or a skip) claims it; the pending placeholder of such a slot is not returned.
recorded row (a take, a skip, or a miss carried in with restored history) claims it; the server's own
placeholder for such a slot is not returned.
type: string
format: date-time
pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
description: Window start (inclusive). Defaults to 90 days before `to`; clamped to a 366-day span floor. Recorded doses
are returned from this instant. A slot from before the medication's `createdAt` appears only when a recorded
dose (a take or a skip) claims it; the pending placeholder of such a slot is not returned.
row (a take, a skip, or a miss carried in with restored history) claims it; the server's own placeholder for
such a slot is not returned.
- in: query
name: to
schema:
@@ -43266,8 +43268,8 @@ components:
minimum: 0
maximum: 9007199254740991
description: "Full denominator over the window: `taken + skipped + missed`. Cadence-aware. A slot from before the
medication's `createdAt` counts only when a recorded dose (a take or a skip) claims it, so the days before
the medication existed are never missed."
medication's `createdAt` counts only when a recorded row (a take, a skip, or a miss carried in with restored
history) claims it, so the days before the medication existed are never missed."
taken:
type: integer
minimum: 0