From 6f20915d7319e75449b65c78ed3684f5d00a5c9a Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 28 Mar 2026 11:16:29 +0100 Subject: [PATCH] fix: Phase 0b - body_progress_score uses correct column name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: Filtered goals by g.get('type_key') but goals table has 'goal_type' column. Result: weight_goals was always empty → _score_weight_trend returned None. Fix: Changed 'type_key' → 'goal_type' (matches goals table schema). Verified: Migration 022 defines goal_type column, not type_key. Co-Authored-By: Claude Opus 4.6 --- backend/calculations/body_metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/calculations/body_metrics.py b/backend/calculations/body_metrics.py index 830dd1f..8a8d942 100644 --- a/backend/calculations/body_metrics.py +++ b/backend/calculations/body_metrics.py @@ -386,7 +386,7 @@ def _score_weight_trend(profile_id: str) -> Optional[int]: from goal_utils import get_active_goals goals = get_active_goals(profile_id) - weight_goals = [g for g in goals if g.get('type_key') == 'weight'] + weight_goals = [g for g in goals if g.get('goal_type') == 'weight'] if not weight_goals: return None