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

- 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:
Lars 2026-03-28 14:33:16 +01:00
parent c90e30806b
commit 370f0d46c7

View File

@ -349,6 +349,11 @@ def list_goals(session: dict = Depends(require_auth)):
goals = [r2d(row) for row in cur.fetchall()] goals = [r2d(row) for row in cur.fetchall()]
print(f"[DEBUG] Loaded {len(goals)} goals for profile {pid}") 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 # Update current values for each goal
for goal in goals: for goal in goals:
try: try:
@ -580,10 +585,19 @@ def update_goal(goal_id: str, data: GoalUpdate, session: dict = Depends(require_
updates.append("updated_at = NOW()") updates.append("updated_at = NOW()")
params.extend([goal_id, pid]) params.extend([goal_id, pid])
cur.execute( update_sql = f"UPDATE goals SET {', '.join(updates)} WHERE id = %s AND profile_id = %s"
f"UPDATE goals SET {', '.join(updates)} WHERE id = %s AND profile_id = %s", print(f"[DEBUG] UPDATE SQL: {update_sql}")
tuple(params) 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"} return {"message": "Ziel aktualisiert"}