mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
fix(analytics): withhold a trend slope when the window's readings cover too few days
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.
This commit is contained in:
1 parent
5a8f59e0c0
commit
c15ff8401b
32 files changed
+850
-247
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$comment": "Production functions over 200 lines, keyed \"file :: name\", and their length. Maintained by src/__tests__/source-size-ratchet.test.ts.",
|
||||
"count": 352,
|
||||
"total": 113991,
|
||||
"total": 113987,
|
||||
"entries": {
|
||||
"app/achievements/page.tsx :: AchievementsPage": 206,
|
||||
"app/api/admin/backups/upload/route.ts :: apiHandler(arg)": 314,
|
||||
@@ -262,7 +262,7 @@
|
||||
"lib/analytics/correlations-fast-path.ts :: computeCorrelationHypothesesFastPath": 256,
|
||||
"lib/analytics/intraday-pulse-io.ts :: loadIntradayPulse": 206,
|
||||
"lib/analytics/score/reader.ts :: computeUserHealthScore": 324,
|
||||
"lib/analytics/summaries-slice.ts :: computeFromRollups": 377,
|
||||
"lib/analytics/summaries-slice.ts :: computeFromRollups": 375,
|
||||
"lib/api-handler.ts :: apiHandler": 207,
|
||||
"lib/api-handler.ts :: apiHandler > wrapped": 201,
|
||||
"lib/auth/profile-update.ts :: applyProfileUpdate": 353,
|
||||
@@ -295,7 +295,7 @@
|
||||
"lib/illness/correlation.ts :: computeIllnessCorrelation": 233,
|
||||
"lib/import/labs-csv.ts :: importLabsCsv": 309,
|
||||
"lib/import/labs-csv.ts :: importLabsCsv > flush": 231,
|
||||
"lib/insights/comprehensive-aggregator.ts :: buildFromRollups": 220,
|
||||
"lib/insights/comprehensive-aggregator.ts :: buildFromRollups": 218,
|
||||
"lib/insights/comprehensive-generate.ts :: generateComprehensiveInsight": 876,
|
||||
"lib/insights/features.ts :: extractFeatures": 796,
|
||||
"lib/insights/mood-aggregates.ts :: fetchMoodAggregates": 246,
|
||||
|
||||
Reference in new issue
Block a user