Add editable notes to workouts

This commit is contained in:
Peter Stockings
2023-07-12 19:35:55 +10:00
parent 19c586c5b2
commit c457002d1e
5 changed files with 203 additions and 129 deletions

12
db.py
View File

@@ -185,7 +185,8 @@ class DataBase():
E.exercise_id AS "ExerciseId",
E.name AS "ExerciseName",
T.repetitions AS "Repetitions",
T.weight AS "Weight"
T.weight AS "Weight",
W.note AS "Note"
FROM Person P
LEFT JOIN Workout W ON P.person_id=W.person_id
LEFT JOIN TopSet T ON W.workout_id=T.workout_id
@@ -193,13 +194,16 @@ class DataBase():
WHERE P.person_id=%s
AND W.workout_id = %s""", [person_id, workout_id])
note = next((t['Note'] for t in topsets), '')
return {
'PersonId': next((t['PersonId'] for t in topsets), -1),
'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]
'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
}
def get_topset(self, person_id, workout_id, topset_id):
@@ -297,3 +301,7 @@ class DataBase():
def delete_tag_for_dashboard(self, tag_id):
self.execute('DELETE FROM Tag WHERE tag_id=%s', [tag_id], commit=True)
def update_workout_note_for_person(self, person_id, workout_id, note):
self.execute('UPDATE workout SET note=%s WHERE person_id=%s AND workout_id=%s', [
note, person_id, workout_id], commit=True)