mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 22:32:04 +00:00
fix(series): follow the source priority ladder in the dense and raw series reads
The rollup tier and sleep resolve every (type, day) to the source the person's ladder picks before they aggregate. The dense and raw reads of /api/measurements/series filtered on user and type only, so with a second provider a day's value blended the two, a reading present in both showed twice, and the configured ladder had no effect on those charts. Both reads now take the ladder-winning source per day through the shared canonicalMeasurementsCte helper, as the other live readers do: - the day and hour bucket read of the dense kinds (pulse, glucose, HRV, SpO2), and the stats strip over its rows; - the generic raw read (weight, body fat, steps, resting heart rate, ...). The collapse is per day for the hour grain too, as everywhere else. The helper gains an optional single-type scope so a series scans one metric, not every row the person has in the window. Only a type that has a ladder is collapsed. For a type without one (glucose, body water, bone mass) the helper breaks the tie by source name, which would silently hide one of two real sources, so those keep every source as before. A single-source account reads exactly what is stored. Tests: a real-database test covering the ladder in both directions, the per-day fallback, a reading mirrored into two sources, the day-bucket, hour- bucket and raw reads, a type with no ladder and a single-source account. The route's unit test file reads its fixtures through a small adapter for the new raw statements, and the dense-read guard drops the exception for the removed findMany. The OpenAPI description states the rule. Refs #1108
This commit is contained in:
1 parent
02b6f06521
commit
bb1acfab64
10 files changed
+566
-57
No files matched your search
@@ -101,8 +101,6 @@ const ALLOWED: Record<string, string> = {
|
||||
"Health-score inputs: steps (drained to one row per day nightly), sleep, waist, weight, blood pressure, fasting glucose only.",
|
||||
'app/api/analytics/route.ts::"BLOOD_GLUCOSE"':
|
||||
"The 30-day per-context glucose summary, the same window and bound as the dashboard and coach glucose panels: at a sensor's fixed rate, below 45 000 rows.",
|
||||
"app/api/measurements/series/route.ts::(shorthand)":
|
||||
"The raw branch of the per-kind series. Every dense kind reaches it only inside 90 days and under 10 000 rows (counted first); the sparse kinds are a few readings a day.",
|
||||
"app/api/measurements/batch/route.ts::p.row.type as MeasurementType":
|
||||
"Cross-source merge probe: one ±tolerance window around each posted reading's instant, so the rows found are bounded by the batch size.",
|
||||
"app/api/measurements/route.ts::(shorthand)":
|
||||
|
||||
Reference in new issue
Block a user