fix: Phase 0b - body_progress_score + placeholder formatting
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

Fixed remaining placeholder calculation issues:

1. body_progress_score returning 0:
   - When start_value is NULL, query oldest weight from last 90 days
   - Prevents progress = 0% when start equals current

2. focus_areas_weighted_json empty:
   - Changed from goal_utils.get_focus_weights_v2() to scores.get_user_focus_weights()
   - Now uses same function as focus_area_weights_json

3. Implemented 5 TODO markdown formatting functions:
   - _format_goals_as_markdown() - table with progress bars
   - _format_focus_areas_as_markdown() - weighted list
   - _format_top_focus_areas() - top N by weight
   - _format_goals_behind() - lowest progress goals
   - _format_goals_on_track() - goals >= 50% progress

All placeholders should now return proper values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 4.6 committed 2026-03-28 12:34:24 +01:00
1 parent b09a7b200a
commit 8da577fe58
2 files changed
+130 -14

No files matched your search

+17 -2
View File
@@ -395,11 +395,26 @@ def _score_weight_trend(profile_id: str) -> Optional[int]:
current = goal.get('current_value')
target = goal.get('target_value')
start = goal.get('start_value', current)
start = goal.get('start_value')
if None in [current, target, start]:
if None in [current, target]:
return None
# If no start_value, use oldest weight in last 90 days
if start is None:
with get_db() as conn:
cur = get_cursor(conn)
cur.execute("""
SELECT weight
FROM weight_log
WHERE profile_id = %s
AND date >= CURRENT_DATE - INTERVAL '90 days'
ORDER BY date ASC
LIMIT 1
""", (profile_id,))
row = cur.fetchone()
start = float(row['weight']) if row else current
# Progress percentage
progress_pct = calculate_goal_progress_pct(current, target, start)