fix: add missing statistics import and update focus_weights function
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

Two critical fixes for placeholder resolution:

1. Missing import in activity_metrics.py:
   - Added 'import statistics' at module level
   - Fixes calculate_monotony_score() and calculate_strain_score()
   - Error: NameError: name 'statistics' is not defined

2. Outdated focus_weights function in body_metrics.py:
   - Changed from goal_utils.get_focus_weights (uses old focus_areas table)
   - To data_layer.scores.get_user_focus_weights (uses new v2.0 system)
   - Fixes calculate_body_progress_score()
   - Error: UndefinedTable: relation "focus_areas" does not exist

These were causing many placeholders to fail silently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-28 20:46:21 +01:00
parent 5b7d7ec3bb
commit 285184ba89
2 changed files with 3 additions and 3 deletions

View File

@ -17,6 +17,7 @@ Version: 1.0
from typing import Dict, List, Optional
from datetime import datetime, timedelta, date
import statistics
from db import get_db, get_cursor, r2d
from data_layer.utils import calculate_confidence, safe_float, safe_int

View File

@ -620,9 +620,8 @@ def calculate_recomposition_quadrant(profile_id: str) -> Optional[str]:
def calculate_body_progress_score(profile_id: str, focus_weights: Optional[Dict] = None) -> Optional[int]:
"""Calculate body progress score (0-100) weighted by user's focus areas"""
if focus_weights is None:
from goal_utils import get_focus_weights
with get_db() as conn:
focus_weights = get_focus_weights(conn, profile_id)
from data_layer.scores import get_user_focus_weights
focus_weights = get_user_focus_weights(profile_id)
weight_loss = focus_weights.get('weight_loss', 0)
muscle_gain = focus_weights.get('muscle_gain', 0)