fix: rest_days schema - use 'focus' column instead of 'rest_type'
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s

Problem: get_rest_days_data() queried non-existent 'rest_type' column
Fix: Changed to 'focus' column with correct values (muscle_recovery, cardio_recovery, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-28 19:28:46 +01:00
parent 6c23973c5d
commit 26110d44b4

View File

@ -227,9 +227,11 @@ def get_rest_days_data(
{
"total_rest_days": int,
"rest_types": {
"strength": int,
"cardio": int,
"relaxation": int
"muscle_recovery": int,
"cardio_recovery": int,
"mental_rest": int,
"deload": int,
"injury": int
},
"rest_frequency": float, # days per week
"confidence": str,
@ -253,25 +255,27 @@ def get_rest_days_data(
total_row = cur.fetchone()
total_count = total_row['count'] if total_row else 0
# Get breakdown by rest type
# Get breakdown by focus type
cur.execute(
"""SELECT rest_type, COUNT(*) as count FROM rest_days
"""SELECT focus, COUNT(*) as count FROM rest_days
WHERE profile_id=%s AND date >= %s
GROUP BY rest_type""",
GROUP BY focus""",
(profile_id, cutoff)
)
type_rows = cur.fetchall()
rest_types = {
"strength": 0,
"cardio": 0,
"relaxation": 0
"muscle_recovery": 0,
"cardio_recovery": 0,
"mental_rest": 0,
"deload": 0,
"injury": 0
}
for row in type_rows:
rest_type = row['rest_type']
if rest_type in rest_types:
rest_types[rest_type] = row['count']
focus = row['focus']
if focus in rest_types:
rest_types[focus] = row['count']
# Calculate frequency (rest days per week)
rest_frequency = (total_count / days * 7) if days > 0 else 0.0