Repository navigation
fix(insights): read today's ranked vitals from the ladder-winning source - #1549
Merged
Merged
Conversation
The metric page and the rollups keep each day of a ranked vital to the source the user put first. Three readers did not: readDayAggregates, behind readiness's latest-day value, the coincident-deviation flag and the vitals baseline's live fold, averaged every source of the day; and the briefing's signals of the day took the raw rows, so the newest row of any source became today's value. With a ring worn at night and a watch worn in the day both reporting resting heart rate for one date, readiness used the mean of the two and moved whenever the lower-ranked watch revised its estimate, and the briefing could quote the watch. readDayAggregates takes the user's source-priority blob and, for a type with a ladder, keeps each day to its first source in ladder order, the order canonicalMeasurementsCte uses. readLatestDayMean and the baseline's live fold pass it; the signals of the day read through canonicalSignalRows, which applies pickCanonicalSourceRows per local day. Refs #1514
The day readers loaded the source-priority blob once per type, so a dashboard, digest or health-status request read the same row a dozen times and went over its statement budget.
A run in the first two minutes after Berlin midnight put the real reading on yesterday, and the deviation it asserts on was never there.
…e-priority # Conflicts: # CHANGELOG.md
…e-priority # Conflicts: # CHANGELOG.md
2 tasks done
…e-priority # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Readiness, the coincident-deviation flag, the vitals baseline's live fold and the briefing's signals of the day mixed every source of a day for ranked vitals, while the metric page shows the ladder-winning source. Two devices reporting resting heart rate for one date produced a readiness value from their mean and a briefing signal from whichever row sorted last.
readDayAggregatesnow takes the source-priority blob and keeps each day to its first source in ladder order;readLatestDayMeanand the baseline's live fold pass it, and the signals of the day read throughcanonicalSignalRows.Test:
tests/integration/today-reads-source-priority.test.ts(four of five cases fail on main, all pass here). Unit mocks of the derived metrics now stub the priority load.Refs #1514