mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Wires readBestGranularityRollups into the WEIGHT-covered branch of computeUserHealthScoreFastPath so the trailing-year weight baseline is served from the WEEK / MONTH / YEAR rollup tier instead of falling through to a live measurements walk. The 365-day window routes through MONTH by default (~12 buckets) and falls back to WEEK -> DAY on per- tier coverage miss. count / mean compose linearly across MONTH buckets so the derived mean is mathematically equivalent to the per-row average over the same window. The read fires in parallel with the canonical DAY-bucket read for the 30-day weight series so wall-clock cost stays flat. Score shape is unchanged; the weightLongWindow annotate carries the resolved granularity + bucket count + mean so operators can verify the rollup tier serves production traffic. The live-fallback branch deliberately omits the long-window probe because the raw weight findMany already does the work — guards against double-reading on cold mounts.