Skip to content

fix(scores): one health score on the start page, last night by one rule - #1579

Merged
MBombeck merged 4 commits into
release/v1.50.0from
fix/150-health-score-consistency
Nov 26, 2026
Merged

MBombeck merged 4 commits into
release/v1.50.0from
fix/150-health-score-consistency

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

Three fixes for the 1.50 freeze.

Health score on / said "not enough data" while /api/analytics showed a number. The dashboard snapshot holds its second phase (and the score with it) back while the rollup tier does not cover blood pressure, weight or steps; /api/analytics computes without that gate. An account whose history was written straight to the table (seed, restore, direct import) keeps readings older than the 90 days the read path folds, so coverage never closed before the next boot. computeAndRecordUserHealthScore now keeps its report in a per-day cell under the account's analytics prefix; a held-back snapshot serves it and requests the account's full fold (coalesced on the boot key, throttled per process). Snapshot, digest and morning all read the snapshot's score, so they now match analytics. Integration test dashboard-health-score-parity fails on the old code (snapshot score undefined vs analytics 95; fold never closes coverage).

Digest reads last night by the morning's rule. sleepPending and the phase used a rolling 24 h window; they now go through resolveLastNight via a shared lastNightFromSnapshot (neutral module, so the digest still never imports the morning loader). The sleep score comes from the morning's day cell when present, without new reads.

Snapshot pillar labels in the app's language. Brings main's resolver change (Bearer Accept-Language first, operator default before English) to the release branch as an identical cherry-pick, and pins the snapshot's pillar names and reasons on a token request in an integration test. Labels reuse the existing insights.healthScore.pillar.* keys (all ten locales), so there is no client growth.

No wire shape change. Query budgets unchanged (query-budget-hot-routes green).

resolveServerLocale now reads the ambient request headers, lets a
Bearer request's Accept-Language outrank the cookie and the stored
language, and falls back to the operator default before English. The
nutrient catalogue, ingredient labels and mood insights resolve through
it instead of the stored language alone.
…r its rollups

The dashboard snapshot holds its second phase, and the health score with
it, back while the rollup tier does not cover blood pressure, weight or
steps. /api/analytics computes the score without that gate. An account
whose history reached the table without the write hooks (seeded,
restored, imported directly) keeps readings older than the 90 days the
read path folds, so its coverage only closed at the next boot: the start
page, the digest and the morning said "not enough data" while Insights
showed a number for the same day.

computeAndRecordUserHealthScore now keeps each report in a per-day cell
under the account's analytics prefix. A held-back snapshot serves that
report and asks for the account's full fold, coalesced on the boot key
and throttled per process, so the phase converges without a restart.

Also pins that the snapshot's pillar rows follow the app's language on a
token request.
The morning decides whether last night is in by the night of the sleep
score (resolveLastNight); the digest still used a rolling 24 hours since
the newest sleep row. A night that ended 23 hours ago counted as last
night in the digest, which settled the day and dropped sleepPending while
the morning beside it still waited for tonight's sleep.

Both loaders now read last night through lastNightFromSnapshot in a
neutral module. The digest takes the sleep score from the morning's own
day cell when the morning has been read, without computing one, and
falls back to the latest sleep row's wake day as the morning does. The
builder's phase, sleepPending and overview sleep line follow the result.
@MBombeck
MBombeck merged commit b12e340 into release/v1.50.0 Nov 26, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant