When you select an exercise for a new topset autofill the reps/weight feilds with the most recent topset values if possible (I beleive I have introduced a minor defect where adding a new set no longer clears reps/weight feild, but for some reason still clears exercise)
This commit is contained in:
25
db.py
25
db.py
@@ -227,7 +227,6 @@ class DataBase():
|
||||
'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'),
|
||||
'WorkoutId': workout_id,
|
||||
'StartDate': topsets[0]['StartDate'],
|
||||
'Exercises': self.get_exercises(),
|
||||
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets if t['TopSetId'] is not None],
|
||||
'Note': note
|
||||
}
|
||||
@@ -439,3 +438,27 @@ class DataBase():
|
||||
selected_workout_tag_ids = [wt['tag_id'] for wt in workout_tags]
|
||||
|
||||
return (person_tags, workout_tags, selected_workout_tag_ids)
|
||||
|
||||
def get_most_recent_topset_for_exercise(self, person_id, exercise_id):
|
||||
topset = self.execute("""
|
||||
SELECT
|
||||
t.repetitions,
|
||||
t.weight
|
||||
FROM
|
||||
topset t JOIN workout w ON t.workout_id = w.workout_id
|
||||
WHERE
|
||||
w.person_id = %s AND t.exercise_id = %s
|
||||
ORDER BY
|
||||
w.start_date DESC
|
||||
LIMIT 1;
|
||||
""", [person_id, exercise_id], one=True)
|
||||
|
||||
if not topset:
|
||||
return None
|
||||
else:
|
||||
return (topset['repetitions'], topset['weight'])
|
||||
|
||||
def get_all_exercises(self):
|
||||
exercises = self.execute(
|
||||
'SELECT exercise_id, name FROM exercise')
|
||||
return exercises
|
||||
|
||||
Reference in New Issue
Block a user