fix: Phase 0b - implement active_goals and focus_areas JSON placeholders
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

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 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-28 12:19:37 +01:00
parent 05d15264c8
commit b09a7b200a

View File

@ -666,8 +666,9 @@ def _get_active_goals_json(profile_id: str) -> str:
"""Get active goals as JSON string""" """Get active goals as JSON string"""
import json import json
try: try:
# TODO: Implement after goal_utils extensions from goal_utils import get_active_goals
return '[]' goals = get_active_goals(profile_id)
return json.dumps(goals, default=str)
except Exception: except Exception:
return '[]' return '[]'
@ -676,8 +677,36 @@ def _get_focus_areas_weighted_json(profile_id: str) -> str:
"""Get focus areas with weights as JSON string""" """Get focus areas with weights as JSON string"""
import json import json
try: try:
# TODO: Implement after goal_utils extensions from goal_utils import get_focus_weights_v2, get_db, get_cursor
return '[]'
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: except Exception:
return '[]' return '[]'