From 1b06d6b6bc7021950873e6a92ca939b51bb112f2 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 1 Dec 2021 20:17:15 +0100 Subject: [PATCH] API - remove useless user query --- fittrackee/workouts/utils.py | 5 ++--- fittrackee/workouts/workouts.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fittrackee/workouts/utils.py b/fittrackee/workouts/utils.py index 015b825b..3c9b463b 100644 --- a/fittrackee/workouts/utils.py +++ b/fittrackee/workouts/utils.py @@ -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'): diff --git a/fittrackee/workouts/workouts.py b/fittrackee/workouts/workouts.py index e0828c11..b0339ad2 100644 --- a/fittrackee/workouts/workouts.py +++ b/fittrackee/workouts/workouts.py @@ -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',