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.
This commit is contained in:
parent
8e67175ed2
commit
294b3b2ece
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user