API - fix workouts sort on duration (= moving time)

This commit is contained in:
Sam
2022-10-26 22:01:00 +02:00
parent 7ea74d51e7
commit 1dc35c379d
2 changed files with 26 additions and 3 deletions

View File

@ -224,8 +224,9 @@ def get_workouts(auth_user: User) -> Union[Dict, HttpResponse]:
ave_speed_to = params.get('ave_speed_to')
max_speed_from = params.get('max_speed_from')
max_speed_to = params.get('max_speed_to')
order_by = params.get('order_by', 'workout_date')
workout_column = getattr(
Workout, params.get('order_by', 'workout_date')
Workout, 'moving' if order_by == 'duration' else order_by
)
order = params.get('order', 'desc')
sport_id = params.get('sport_id')