Ensure workouts are printed in order of start date descending
This commit is contained in:
2
app.py
2
app.py
@@ -299,6 +299,8 @@ def my_utility_processor():
|
||||
return db.get_people_and_workout_count(person_id)
|
||||
|
||||
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
|
||||
if not list:
|
||||
return None
|
||||
for element in list:
|
||||
if element[attribute] == value:
|
||||
return element
|
||||
|
||||
3
utils.py
3
utils.py
@@ -17,6 +17,9 @@ def get_workouts(topsets):
|
||||
'StartDate': topsets_in_workout[0]['StartDate'],
|
||||
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets_in_workout if t['TopSetId'] is not None]
|
||||
})
|
||||
|
||||
workouts.sort(key=lambda x: x['StartDate'], reverse=True)
|
||||
|
||||
return workouts
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user