Goals -System refactored - Platzhaltersystem enhanced (als draft) #53

Merged
Lars merged 86 commits from develop into main 2026-03-31 11:46:48 +02:00
Showing only changes of commit 370f0d46c7 - Show all commits

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"}