mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
Adds `computeLongWindowSummary(userId, type, windowDays)` — the ready-to-use entry point for the v1.5 multi-year trend card and the Coach drawer's "history" tile. Routes the requested window through the largest granularity that still resolves it (90 d \u2192 DAY, 365 d \u2192 MONTH, 1095 d \u2192 YEAR) via `readBestGranularityRollups`, then composes `count / min / max / mean / sum` linearly from the bucket rows. SD / slope / r2 are intentionally omitted because they do not compose across coarser buckets. The existing `computeSummariesSlice` shape is untouched — its windowed columns cap at 90 d so the live SQL path is already DAY-tier optimal. Wiring the all-time aggregate through YEAR buckets would risk staleness on multi-year data because the WEEK / MONTH / YEAR tiers update asynchronously via pg-boss while DAY is kept fresh by the sync write-hook. Deferring that swap to v1.5 (covered in the W-WMY phase report).