From 919eae60536ae8d50182eded13ef003fb5aca771 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 28 Mar 2026 09:42:54 +0100 Subject: [PATCH] fix: Phase 0b - sleep dict access in health_stability_score regularity --- backend/calculations/scores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/calculations/scores.py b/backend/calculations/scores.py index 108408b..076de8d 100644 --- a/backend/calculations/scores.py +++ b/backend/calculations/scores.py @@ -274,7 +274,7 @@ def calculate_health_stability_score(profile_id: str) -> Optional[int]: # 5. Regularity (10%) - sleep timing consistency if len(sleep_data) >= 7: - sleep_times = [s['total_sleep_min'] for s in sleep_data] + sleep_times = [s['duration_minutes'] for s in sleep_data] avg = sum(sleep_times) / len(sleep_times) variance = sum((x - avg) ** 2 for x in sleep_times) / len(sleep_times) std_dev = variance ** 0.5