Add button to topsets to show history as a table

This commit is contained in:
Peter Stockings
2026-02-26 23:26:49 +11:00
parent 67009c9603
commit 895b813a35
4 changed files with 127 additions and 19 deletions

22
db.py
View File

@@ -380,6 +380,28 @@ class DataBase():
return None
else:
return (topset.get('repetitions'), topset.get('weight'), topset['exercise_name'])
def get_recent_topsets_for_exercise(self, person_id, exercise_id, limit=5, offset=0):
topsets = self.execute("""
SELECT
t.topset_id,
t.repetitions,
t.weight,
w.start_date,
w.workout_id,
e.name AS "exercise_name"
FROM
exercise e
JOIN topset t ON e.exercise_id = t.exercise_id
JOIN workout w ON t.workout_id = w.workout_id
WHERE
e.exercise_id = %s AND w.person_id = %s
ORDER BY
w.start_date DESC, t.topset_id DESC
LIMIT %s OFFSET %s;
""", [exercise_id, person_id, limit, offset])
return topsets
def get_all_exercises(self):
return self.exercises.get("")