mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(insights): let the lab-comparison card age out, and give its delta the row's tier
Two things about the card that shows what changed since the last panel. The comparison had no expiry. Someone whose newest panel is years old was still reading "since your last panel" about a draw from another year — not stale UI state but a stale sentence, and one the app kept repeating on the overview every day. The window is a year, applied to the data rather than to a per-user dismissal. A year because routine panels are commonly drawn annually, so a shorter window would hide a comparison that is genuinely the newest thing somebody has for months out of every year, while past a year the wording cannot be defended at all. Doing it on the data means nothing to acknowledge, nothing to persist, no housekeeping asked of anyone, and one answer for every client through the existing absent contract — the card already un-mounts on it, and so does anything else reading that route. Verified in both directions over the real endpoint. The delta on the right was muted at the smaller size, the same typography as the meta line under the analyte, so it optically hung off that lower line and the row read as bottom-aligned even though it measures centred to the pixel at every width. A delta is the number the row exists to report, so it takes the content tier, and the cell states its own centring rather than inheriting it. The existing cases pinned their clock at the same time: fixed fixture days against a relative window is a test that passes until a date in the future and then fails for reasons unrelated to the code.
This commit is contained in:
1 parent
41faf165ee
commit
190941944c
4 files changed
+140
-21
No files matched your search
@@ -6,8 +6,10 @@
|
||||
* Groups the user's live numeric lab results by panel date, pairs the two
|
||||
* most-recent panels, and reports the per-analyte delta + reference-band
|
||||
* standing (`summariseLabChanges`). Absent when there are fewer than two
|
||||
* panels or no analyte is shared. Neutral framing only — a delta is not a
|
||||
* diagnosis.
|
||||
* panels, no analyte is shared, or the newest panel is older than the
|
||||
* recency window — the card's "since your last panel" wording is a claim
|
||||
* about recent news, and it stops being made rather than being made about a
|
||||
* years-old draw. Neutral framing only — a delta is not a diagnosis.
|
||||
*
|
||||
* Mirrors `/api/insights/derived`: `apiHandler`, `requireAuth`, the `insights`
|
||||
* module gate, the shared analytics-read budget. `userId` is narrowed from the
|
||||
@@ -62,7 +64,13 @@ export const GET = apiHandler(async () => {
|
||||
|
||||
annotate({
|
||||
action: { name: "insights.labs-changes.read" },
|
||||
meta: { present: summary.present, changes: summary.changes.length },
|
||||
meta: {
|
||||
present: summary.present,
|
||||
changes: summary.changes.length,
|
||||
// Distinguishes "no comparable panels" from "the comparison aged out",
|
||||
// so an absent card is diagnosable without reaching for the database.
|
||||
lab_rows: rows.length,
|
||||
},
|
||||
});
|
||||
|
||||
return apiSuccess({ ...summary, generatedAt: new Date().toISOString() });
|
||||
|
||||
Reference in new issue
Block a user