mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The generic metric-status generator read SLEEP_DURATION row-per-stage and fed the snapshot a single sleep STAGE (~16 min) as the current value, so the sleep prose reported a fraction of an hour for a full night. Route the SLEEP_DURATION status/snapshot through reconstructSleepNights — the same per-night, source-deduped, midnight-aware time-asleep total the dashboard, series, and targets surfaces use — so the snapshot's series, summary, and latest value are all the night total in minutes (the registry unit and normal range are already minutes). Gated to SLEEP_DURATION; no other metric's status path changes. The readiness wellness index could surface a contributor value of 0 for an account that recorded resting heart rate / HRV / respiratory rate but had no scorable baseline: a non-finite baseline center or today value fell through clamp100 to a misleading 0 that reads as a real worst-case sub-score. Return null instead so the client drops the contributor, and document the null-vs-0 contract: null means no usable signal (no baseline, no recent reading, non-finite input); a finite value — including a genuine 0 — means the baseline is established and the latest reading really deviates that far. (cherry picked from commit 0422ac012765f30069a41f662c2b025197ed9a88)