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 <noreply@anthropic.com>
This commit is contained in:
parent
05d15264c8
commit
b09a7b200a
|
|
@ -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 '[]'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user