fix: Phase 0b - sleep dict access in health_stability_score regularity
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s

This commit is contained in:
Lars 2026-03-28 09:42:54 +01:00
parent 91bafc6af1
commit 919eae6053

View File

@ -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