V 0.9h dynamic focus area system #51

Merged
Lars merged 11 commits from develop into main 2026-03-27 21:14:40 +01:00
Showing only changes of commit 029530e078 - Show all commits

View File

@ -201,17 +201,32 @@ def get_focus_areas(session: dict = Depends(require_auth)):
with get_db() as conn: with get_db() as conn:
cur = get_cursor(conn) cur = get_cursor(conn)
# Try to get custom focus areas # Try to get custom focus areas (user_focus_preferences after Migration 031)
cur.execute(""" try:
SELECT weight_loss_pct, muscle_gain_pct, strength_pct, cur.execute("""
endurance_pct, flexibility_pct, health_pct, SELECT weight_loss_pct, muscle_gain_pct, strength_pct,
created_at, updated_at endurance_pct, flexibility_pct, health_pct,
FROM focus_areas created_at, updated_at
WHERE profile_id = %s AND active = true FROM user_focus_preferences
LIMIT 1 WHERE profile_id = %s
""", (pid,)) LIMIT 1
""", (pid,))
row = cur.fetchone() row = cur.fetchone()
except Exception as e:
# Migration 031 not applied yet, try old table name
print(f"[WARNING] user_focus_preferences not found, trying old focus_areas: {e}")
try:
cur.execute("""
SELECT weight_loss_pct, muscle_gain_pct, strength_pct,
endurance_pct, flexibility_pct, health_pct,
created_at, updated_at
FROM focus_areas
WHERE profile_id = %s AND active = true
LIMIT 1
""", (pid,))
row = cur.fetchone()
except:
row = None
if row: if row:
return { return {