From b09a7b200a8b618cc11271ed6bf7a4de54f55ce7 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 28 Mar 2026 12:19:37 +0100 Subject: [PATCH] fix: Phase 0b - implement active_goals and focus_areas JSON placeholders Root cause: Two TODO stubs always returned '[]' Implemented: - active_goals_json: Calls get_active_goals() from goal_utils - focus_areas_weighted_json: Builds weighted list with names/categories Result: - active_goals_json now shows actual goals - body_progress_score should calculate correctly - top_3_goals placeholders will work Co-Authored-By: Claude Opus 4.6 --- backend/placeholder_resolver.py | 37 +++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/backend/placeholder_resolver.py b/backend/placeholder_resolver.py index b734eea..985b522 100644 --- a/backend/placeholder_resolver.py +++ b/backend/placeholder_resolver.py @@ -666,8 +666,9 @@ def _get_active_goals_json(profile_id: str) -> str: """Get active goals as JSON string""" import json try: - # TODO: Implement after goal_utils extensions - return '[]' + from goal_utils import get_active_goals + goals = get_active_goals(profile_id) + return json.dumps(goals, default=str) except Exception: return '[]' @@ -676,8 +677,36 @@ def _get_focus_areas_weighted_json(profile_id: str) -> str: """Get focus areas with weights as JSON string""" import json try: - # TODO: Implement after goal_utils extensions - return '[]' + from goal_utils import get_focus_weights_v2, get_db, get_cursor + + weights = get_focus_weights_v2(get_db(), profile_id) + + # Get focus area details + with get_db() as conn: + cur = get_cursor(conn) + cur.execute(""" + SELECT area_key, name_de, name_en, category + FROM focus_area_definitions + WHERE is_active = true + """) + definitions = {row['area_key']: row for row in cur.fetchall()} + + # Build weighted list + result = [] + for area_key, weight in weights.items(): + if weight > 0 and area_key in definitions: + area = definitions[area_key] + result.append({ + 'key': area_key, + 'name': area['name_de'], + 'category': area['category'], + 'weight': weight + }) + + # Sort by weight descending + result.sort(key=lambda x: x['weight'], reverse=True) + + return json.dumps(result, default=str) except Exception: return '[]'