fix: Phase 0b - fix remaining calculation bugs from log analysis
Bugs fixed based on actual error logs:
1. TypeError: progress_pct None handling - changed .get('progress_pct', 0) to (goal.get('progress_pct') or 0)
2. UUID Error: focus_area_id query - changed WHERE focus_area_id = %s to WHERE key = %s
3. NameError: calculate_recovery_score_v2 - added missing import in calculate_category_progress
4. UndefinedColumn: c_thigh_r - removed left/right separation, only c_thigh exists
5. UndefinedColumn: resting_heart_rate - fixed remaining AVG(resting_heart_rate) to AVG(resting_hr)
6. KeyError: total_sleep_min - changed dict access to duration_minutes
Changes:
- scores.py: Fixed progress_pct None handling, focus_area key query, added recovery import
- body_metrics.py: Fixed thigh_28d_delta to use single c_thigh column
- recovery_metrics.py: Fixed resting_hr SELECT queries, fixed sleep_debt dict access
All errors from logs should now be resolved.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd3a4111fc
commit
02394ea19c
3 files changed
+10
-10
No files matched your search
@@ -224,14 +224,13 @@ def calculate_arm_28d_delta(profile_id: str) -> Optional[float]:
|
||||
|
||||
|
||||
def calculate_thigh_28d_delta(profile_id: str) -> Optional[float]:
|
||||
"""Calculate 28-day thigh circumference change (cm, average of L/R)"""
|
||||
left = _calculate_circumference_delta(profile_id, 'c_thigh', 28)
|
||||
right = _calculate_circumference_delta(profile_id, 'c_thigh_r', 28)
|
||||
"""Calculate 28-day thigh circumference change (cm)"""
|
||||
delta = _calculate_circumference_delta(profile_id, 'c_thigh', 28)
|
||||
|
||||
if left is None or right is None:
|
||||
if delta is None:
|
||||
return None
|
||||
|
||||
return round((left + right) / 2, 1)
|
||||
return round(delta, 1)
|
||||
|
||||
|
||||
def _calculate_circumference_delta(profile_id: str, column: str, days: int) -> Optional[float]:
|
||||
|
||||
Reference in new issue
Block a user