Fix issue selecting a new exercise

This commit is contained in:
Peter Stockings
2025-01-19 21:34:45 +11:00
parent da73d816d6
commit 5ffb08a994
4 changed files with 16 additions and 15 deletions

15
db.py
View File

@@ -460,22 +460,23 @@ class DataBase():
SELECT
t.repetitions,
t.weight,
e.name as "exercise_name"
e.name AS "exercise_name"
FROM
topset t JOIN workout w ON t.workout_id = w.workout_id
JOIN exercise e ON t.exercise_id = e.exercise_id
exercise e
LEFT JOIN topset t ON e.exercise_id = t.exercise_id
LEFT JOIN workout w ON t.workout_id = w.workout_id
WHERE
w.person_id = %s AND t.exercise_id = %s
e.exercise_id = %s AND (w.person_id = %s OR w.person_id IS NULL)
ORDER BY
w.start_date DESC
LIMIT 1;
""", [person_id, exercise_id], one=True)
""", [exercise_id, person_id], one=True)
if not topset:
return None
else:
return (topset['repetitions'], topset['weight'], topset['exercise_name'])
return (topset.get('repetitions'), topset.get('weight'), topset['exercise_name'])
def get_all_exercises(self):
exercises = self.execute(
'SELECT exercise_id, name FROM exercise')