debug: extensive logging for start_date persistence
- Log UPDATE SQL and parameters - Verify saved values after UPDATE - Show date types in list_goals response - Track down why start_date not visible in UI
This commit is contained in:
parent
c90e30806b
commit
370f0d46c7
|
|
@ -349,6 +349,11 @@ def list_goals(session: dict = Depends(require_auth)):
|
|||
goals = [r2d(row) for row in cur.fetchall()]
|
||||
print(f"[DEBUG] Loaded {len(goals)} goals for profile {pid}")
|
||||
|
||||
# Debug: Show first goal with dates
|
||||
if goals:
|
||||
first = goals[0]
|
||||
print(f"[DEBUG] First goal dates: start_date={first.get('start_date')} (type: {type(first.get('start_date'))}), target_date={first.get('target_date')} (type: {type(first.get('target_date'))})")
|
||||
|
||||
# Update current values for each goal
|
||||
for goal in goals:
|
||||
try:
|
||||
|
|
@ -580,10 +585,19 @@ def update_goal(goal_id: str, data: GoalUpdate, session: dict = Depends(require_
|
|||
updates.append("updated_at = NOW()")
|
||||
params.extend([goal_id, pid])
|
||||
|
||||
cur.execute(
|
||||
f"UPDATE goals SET {', '.join(updates)} WHERE id = %s AND profile_id = %s",
|
||||
tuple(params)
|
||||
)
|
||||
update_sql = f"UPDATE goals SET {', '.join(updates)} WHERE id = %s AND profile_id = %s"
|
||||
print(f"[DEBUG] UPDATE SQL: {update_sql}")
|
||||
print(f"[DEBUG] UPDATE params: {params}")
|
||||
|
||||
cur.execute(update_sql, tuple(params))
|
||||
|
||||
# Verify what was actually saved
|
||||
cur.execute("""
|
||||
SELECT id, goal_type, start_date, start_value, target_date, target_value
|
||||
FROM goals WHERE id = %s
|
||||
""", (goal_id,))
|
||||
saved_goal = cur.fetchone()
|
||||
print(f"[DEBUG] After UPDATE, goal in DB: {r2d(saved_goal)}")
|
||||
|
||||
return {"message": "Ziel aktualisiert"}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user