fix: add missing statistics import and update focus_weights function
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:
parent
5b7d7ec3bb
commit
285184ba89
|
|
@ -17,6 +17,7 @@ Version: 1.0
|
||||||
|
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from datetime import datetime, timedelta, date
|
from datetime import datetime, timedelta, date
|
||||||
|
import statistics
|
||||||
from db import get_db, get_cursor, r2d
|
from db import get_db, get_cursor, r2d
|
||||||
from data_layer.utils import calculate_confidence, safe_float, safe_int
|
from data_layer.utils import calculate_confidence, safe_float, safe_int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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]:
|
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"""
|
"""Calculate body progress score (0-100) weighted by user's focus areas"""
|
||||||
if focus_weights is None:
|
if focus_weights is None:
|
||||||
from goal_utils import get_focus_weights
|
from data_layer.scores import get_user_focus_weights
|
||||||
with get_db() as conn:
|
focus_weights = get_user_focus_weights(profile_id)
|
||||||
focus_weights = get_focus_weights(conn, profile_id)
|
|
||||||
|
|
||||||
weight_loss = focus_weights.get('weight_loss', 0)
|
weight_loss = focus_weights.get('weight_loss', 0)
|
||||||
muscle_gain = focus_weights.get('muscle_gain', 0)
|
muscle_gain = focus_weights.get('muscle_gain', 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user