Files
HealthLog/src/lib
Marc-André Bombeck b2a5f2c410 feat(rollups): populate sum_value alongside mean/count in every fold
The v1.4.39 schema scaffolding added `measurement_rollups.sum_value`
for the cumulative-metric daily totals (steps, flights, distance,
daylight, active-energy). Extends the rollup aggregator to also `SUM`
each bucket and persist the column for every (user, type,
granularity, bucket) row regardless of metric kind — spot metrics
carry the column for free because the SUM rides on the same
$queryRaw aggregate as AVG / MIN / MAX / STDDEV_POP / REGR_*.

Boot-time backfill discovery now unions in users whose existing DAY
rollup rows carry `sum_value IS NULL`. Re-folding converges those
rows because `persistRollupRows` always writes the new column on
upsert, and the union runs as one indexed pass alongside the per-
type missing-coverage discovery.

Adds `src/lib/measurements/rollup-read-cumulative.ts` with the new
`readCumulativeDaySums` / `readCumulativeDaySumsBatch` helpers
consumers use to swap off the per-type chunked findMany loop.
Helpers fall back to `mean * count` when the legacy NULL surfaces so
the chart never paints a hole during the boot-backfill convergence
window.

Audit anchor: .planning/round-v1438-perf-analysis.md §3 (cumulative
daily sums) + §5 P3.
2026-05-18 12:17:21 +02:00
..
2026-05-17 19:07:03 +02:00
2026-05-14 23:49:32 +02:00
2026-05-17 23:46:09 +02:00
2026-05-17 19:07:03 +02:00
2026-05-16 10:59:42 +02:00
2026-05-17 19:07:03 +02:00
2026-05-15 22:59:10 +02:00
2026-05-17 19:07:03 +02:00
2026-05-15 22:59:10 +02:00
2026-05-18 06:27:02 +02:00
2026-05-14 23:49:32 +02:00
2026-05-17 19:07:03 +02:00
2026-03-10 20:14:33 +01:00
2026-05-17 23:46:09 +02:00
2026-05-16 16:04:21 +02:00
2026-05-16 12:37:55 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-17 19:07:03 +02:00
2026-05-17 19:07:03 +02:00
2026-05-15 22:59:10 +02:00
2026-05-17 19:07:03 +02:00
2026-05-16 16:04:21 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-15 22:59:10 +02:00
2026-05-15 22:59:10 +02:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-05-15 22:59:10 +02:00
2026-05-14 23:49:32 +02:00
2026-05-17 23:46:09 +02:00
2026-03-10 20:14:33 +01:00