debug: extensive logging for behind_schedule/on_track calculation
All checks were successful
Deploy Development / deploy (push) Successful in 54s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

- 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.
This commit is contained in:
Lars 2026-03-28 15:07:31 +01:00
parent 8e67175ed2
commit 294b3b2ece

View File

@ -824,19 +824,26 @@ def _format_goals_behind(profile_id: str, n: int = 3) -> str:
today = date.today() today = date.today()
goals_with_deviation = [] goals_with_deviation = []
print(f"[DEBUG] _format_goals_behind: Processing {len(goals)} goals")
for g in goals: for g in goals:
goal_name = g.get('name') or g.get('goal_type', 'Unknown')
current = g.get('current_value') current = g.get('current_value')
target = g.get('target_value') target = g.get('target_value')
start = g.get('start_value') start = g.get('start_value')
start_date = g.get('start_date') start_date = g.get('start_date')
target_date = g.get('target_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 # Skip if missing required values
if None in [current, target, start]: if None in [current, target, start]:
print(f"[DEBUG] → Skipped: Missing current/target/start")
continue continue
# Skip if no target_date (can't calculate time-based progress) # Skip if no target_date (can't calculate time-based progress)
if not target_date: if not target_date:
print(f"[DEBUG] → Skipped: No target_date")
continue continue
try: try:
@ -882,8 +889,10 @@ def _format_goals_behind(profile_id: str, n: int = 3) -> str:
g['_expected_progress'] = int(expected_progress_pct) g['_expected_progress'] = int(expected_progress_pct)
g['_deviation'] = int(deviation) g['_deviation'] = int(deviation)
goals_with_deviation.append(g) 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 continue
if not goals_with_deviation: if not goals_with_deviation:
@ -933,19 +942,26 @@ def _format_goals_on_track(profile_id: str, n: int = 3) -> str:
today = date.today() today = date.today()
goals_with_deviation = [] goals_with_deviation = []
print(f"[DEBUG] _format_goals_on_track: Processing {len(goals)} goals")
for g in goals: for g in goals:
goal_name = g.get('name') or g.get('goal_type', 'Unknown')
current = g.get('current_value') current = g.get('current_value')
target = g.get('target_value') target = g.get('target_value')
start = g.get('start_value') start = g.get('start_value')
start_date = g.get('start_date') start_date = g.get('start_date')
target_date = g.get('target_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 # Skip if missing required values
if None in [current, target, start]: if None in [current, target, start]:
print(f"[DEBUG] → Skipped: Missing current/target/start")
continue continue
# Skip if no target_date # Skip if no target_date
if not target_date: if not target_date:
print(f"[DEBUG] → Skipped: No target_date")
continue continue
try: 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['_expected_progress'] = int(expected_progress_pct)
g['_deviation'] = int(deviation) g['_deviation'] = int(deviation)
goals_with_deviation.append(g) 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 continue
if not goals_with_deviation: if not goals_with_deviation: