API - remove useless user query

This commit is contained in:
Sam 2021-12-01 20:17:15 +01:00
parent 1697f6051f
commit 1b06d6b6bc
2 changed files with 3 additions and 4 deletions

View File

@ -186,7 +186,7 @@ def update_workout(workout: Workout) -> Workout:
def edit_workout(
workout: Workout, workout_data: Dict, auth_user_id: int
workout: Workout, workout_data: Dict, auth_user: User
) -> Workout:
"""
Edit an workout
@ -195,7 +195,6 @@ def edit_workout(
In a next version, map_data and weather_data will be updated
(case of a modified gpx file, see issue #7)
"""
user = User.query.filter_by(id=auth_user_id).first()
if workout_data.get('refresh'):
workout = update_workout(workout)
if workout_data.get('sport_id'):
@ -210,7 +209,7 @@ def edit_workout(
workout_data['workout_date'], '%Y-%m-%d %H:%M'
)
_, workout.workout_date = get_datetime_with_tz(
user.timezone, workout_date
auth_user.timezone, workout_date
)
if workout_data.get('duration'):

View File

@ -1288,7 +1288,7 @@ def update_workout(
if response_object:
return response_object
workout = edit_workout(workout, workout_data, auth_user.id)
workout = edit_workout(workout, workout_data, auth_user)
db.session.commit()
return {
'status': 'success',