From ffa99f10fbf6a0db3d95f1669696b7767cb4d2f3 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 28 Mar 2026 21:03:22 +0100 Subject: [PATCH] fix: correct confidence thresholds for 30-89 day range Bug: 30 days with 29 data points returned 'insufficient' because it fell into the 90+ day branch which requires >= 30 data points. Fix: Changed condition from 'days_requested <= 28' to 'days_requested < 90' so that 8-89 day ranges use the medium-term thresholds: - high >= 18 data points - medium >= 12 - low >= 8 This means 30 days with 29 entries now returns 'high' confidence. Affects: nutrition_avg, and all other medium-term metrics. Co-Authored-By: Claude Opus 4.6 --- backend/data_layer/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/data_layer/utils.py b/backend/data_layer/utils.py index d9c460a..c971326 100644 --- a/backend/data_layer/utils.py +++ b/backend/data_layer/utils.py @@ -91,7 +91,8 @@ def calculate_confidence( else: return "insufficient" - elif days_requested <= 28: + elif days_requested < 90: + # 8-89 days: Medium-term analysis if data_points >= 18: return "high" elif data_points >= 12: @@ -101,7 +102,7 @@ def calculate_confidence( else: return "insufficient" - else: # 90+ days + else: # 90+ days: Long-term analysis if data_points >= 60: return "high" elif data_points >= 40: