mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
A least-squares slope per day over readings minutes apart explodes: three blood-pressure readings in one sitting, the only ones of the week, fitted thousands of mmHg per day, and the dashboard tile printed seven days of it as the 7-day trend. The 30-day fallback had the same flaw. A window now earns a slope only when its readings fall on at least three UTC days whose first and last lie at least half the window apart (4 days for the 7-day window, 15 for the 30-day one). The rule lives once in window-confidence.ts and gates every path that publishes a windowed trend: trendSlope (summarize and its callers), the rollup composition and the live REGR_SLOPE fallback of the summaries slice and the comprehensive aggregator, and the per-bucket slope of folded week, month and year buckets. Slope, direction and confidence are present or absent together. The fit itself stays over individual readings, as the window means do. The parity snapshots change only where the fixture falls short of the rule: a weekly body-fat series has two days in its 7-day window, and a ten-day oxygen-saturation series spans nine days of its 30-day window.