fix: Phase 0b - score functions use English focus area keys
Root cause: All 3 score functions returned None because they queried German focus area keys that don't exist in database (migration 031 uses English keys). Changes: - body_progress_score: körpergewicht/körperfett/muskelmasse → weight_loss/muscle_gain/body_recomposition - nutrition_score: ernährung_basis/proteinzufuhr/kalorienbilanz → protein_intake/calorie_balance/macro_consistency/meal_timing/hydration - activity_score: kraftaufbau/cardio/bewegungsumfang/trainingsqualität → strength/aerobic_endurance/flexibility/rhythm/coordination (grouped) Result: Scores now calculate correctly with existing focus area weights. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
63bd103b2c
commit
cc76ae677b
3 files changed
+85
-73
No files matched your search
@@ -339,12 +339,12 @@ def calculate_body_progress_score(profile_id: str, focus_weights: Optional[Dict]
|
||||
from calculations.scores import get_user_focus_weights
|
||||
focus_weights = get_user_focus_weights(profile_id)
|
||||
|
||||
# Get all body-related focus area weights
|
||||
body_weight = focus_weights.get('körpergewicht', 0)
|
||||
body_fat_weight = focus_weights.get('körperfett', 0)
|
||||
muscle_weight = focus_weights.get('muskelmasse', 0)
|
||||
# Get all body-related focus area weights (English keys from DB)
|
||||
weight_loss = focus_weights.get('weight_loss', 0)
|
||||
muscle_gain = focus_weights.get('muscle_gain', 0)
|
||||
body_recomp = focus_weights.get('body_recomposition', 0)
|
||||
|
||||
total_body_weight = body_weight + body_fat_weight + muscle_weight
|
||||
total_body_weight = weight_loss + muscle_gain + body_recomp
|
||||
|
||||
if total_body_weight == 0:
|
||||
return None # No body-related goals
|
||||
@@ -352,23 +352,23 @@ def calculate_body_progress_score(profile_id: str, focus_weights: Optional[Dict]
|
||||
# Calculate component scores (0-100)
|
||||
components = []
|
||||
|
||||
# Weight trend component (if weight goal active)
|
||||
if body_weight > 0:
|
||||
# Weight trend component (if weight loss goal active)
|
||||
if weight_loss > 0:
|
||||
weight_score = _score_weight_trend(profile_id)
|
||||
if weight_score is not None:
|
||||
components.append(('weight', weight_score, body_weight))
|
||||
components.append(('weight', weight_score, weight_loss))
|
||||
|
||||
# Body composition component (if BF% or LBM goal active)
|
||||
if body_fat_weight > 0 or muscle_weight > 0:
|
||||
# Body composition component (if muscle gain or recomp goal active)
|
||||
if muscle_gain > 0 or body_recomp > 0:
|
||||
comp_score = _score_body_composition(profile_id)
|
||||
if comp_score is not None:
|
||||
components.append(('composition', comp_score, body_fat_weight + muscle_weight))
|
||||
components.append(('composition', comp_score, muscle_gain + body_recomp))
|
||||
|
||||
# Waist circumference component (proxy for health)
|
||||
waist_score = _score_waist_trend(profile_id)
|
||||
if waist_score is not None:
|
||||
# Waist gets 20% base weight + bonus from BF% goals
|
||||
waist_weight = 20 + (body_fat_weight * 0.3)
|
||||
# Waist gets 20% base weight + bonus from weight loss goals
|
||||
waist_weight = 20 + (weight_loss * 0.3)
|
||||
components.append(('waist', waist_score, waist_weight))
|
||||
|
||||
if not components:
|
||||
|
||||
Reference in new issue
Block a user