From 294b3b2ece3468eb2ed8fd982328b573b7fa0746 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 28 Mar 2026 15:07:31 +0100 Subject: [PATCH] debug: extensive logging for behind_schedule/on_track calculation - Log each goal processing (name, values, dates) - Log skip reasons (missing values, no target_date) - Log exceptions during calculation - Log successful additions with calculated values This will reveal why Weight goal (+7% ahead) is not showing up. --- backend/placeholder_resolver.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/backend/placeholder_resolver.py b/backend/placeholder_resolver.py index ba628dd..5b4a037 100644 --- a/backend/placeholder_resolver.py +++ b/backend/placeholder_resolver.py @@ -824,19 +824,26 @@ def _format_goals_behind(profile_id: str, n: int = 3) -> str: today = date.today() goals_with_deviation = [] + print(f"[DEBUG] _format_goals_behind: Processing {len(goals)} goals") + for g in goals: + goal_name = g.get('name') or g.get('goal_type', 'Unknown') current = g.get('current_value') target = g.get('target_value') start = g.get('start_value') start_date = g.get('start_date') target_date = g.get('target_date') + print(f"[DEBUG] Goal '{goal_name}': current={current}, target={target}, start={start}, start_date={start_date}, target_date={target_date}") + # Skip if missing required values if None in [current, target, start]: + print(f"[DEBUG] → Skipped: Missing current/target/start") continue # Skip if no target_date (can't calculate time-based progress) if not target_date: + print(f"[DEBUG] → Skipped: No target_date") continue try: @@ -882,8 +889,10 @@ def _format_goals_behind(profile_id: str, n: int = 3) -> str: g['_expected_progress'] = int(expected_progress_pct) g['_deviation'] = int(deviation) goals_with_deviation.append(g) + print(f"[DEBUG] → Added: actual={int(actual_progress_pct)}%, expected={int(expected_progress_pct)}%, deviation={int(deviation)}%") - except (ValueError, ZeroDivisionError, TypeError): + except (ValueError, ZeroDivisionError, TypeError) as e: + print(f"[DEBUG] → Exception: {type(e).__name__}: {e}") continue if not goals_with_deviation: @@ -933,19 +942,26 @@ def _format_goals_on_track(profile_id: str, n: int = 3) -> str: today = date.today() goals_with_deviation = [] + print(f"[DEBUG] _format_goals_on_track: Processing {len(goals)} goals") + for g in goals: + goal_name = g.get('name') or g.get('goal_type', 'Unknown') current = g.get('current_value') target = g.get('target_value') start = g.get('start_value') start_date = g.get('start_date') target_date = g.get('target_date') + print(f"[DEBUG] Goal '{goal_name}': current={current}, target={target}, start={start}, start_date={start_date}, target_date={target_date}") + # Skip if missing required values if None in [current, target, start]: + print(f"[DEBUG] → Skipped: Missing current/target/start") continue # Skip if no target_date if not target_date: + print(f"[DEBUG] → Skipped: No target_date") continue try: @@ -989,8 +1005,10 @@ def _format_goals_on_track(profile_id: str, n: int = 3) -> str: g['_expected_progress'] = int(expected_progress_pct) g['_deviation'] = int(deviation) goals_with_deviation.append(g) + print(f"[DEBUG] → Added: actual={int(actual_progress_pct)}%, expected={int(expected_progress_pct)}%, deviation={int(deviation)}%") - except (ValueError, ZeroDivisionError, TypeError): + except (ValueError, ZeroDivisionError, TypeError) as e: + print(f"[DEBUG] → Exception: {type(e).__name__}: {e}") continue if not goals_with_deviation: