From 9b43d7a8f4c06ac7d5a9fe4021dfe9c70974cbc5 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Fri, 13 Oct 2023 19:05:58 +1100 Subject: [PATCH] Revert logic for lazy loading workout list, instead just load it all when requested --- app.py | 13 +++---------- templates/partials/workouts_list_fragment.html | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index 88ff016..59db4ef 100644 --- a/app.py +++ b/app.py @@ -289,9 +289,7 @@ def calendar_view(user_id): @ app.route("/user//workout/list", methods=['GET']) def workout_list(user_id): - max_date = request.args.get( - 'min_date', default=datetime.now().date(), type=toDate) - workouts = get_workouts_for_user(user_id, max_date=max_date) + workouts = get_workouts_for_user(user_id) return render_template('partials/workouts_list_fragment.html', workouts=workouts, user_id=user_id) @@ -367,13 +365,8 @@ def render_users_and_workouts(): def get_workouts_for_user(user_id, max_date=None): user = User.query.get(user_id) workouts_data = [] - workouts = [] - if max_date: - workouts = Workout.query.filter_by(user_id=user_id).filter( - Workout.started_at < max_date).order_by(Workout.created_at.desc()).all() - else: - workouts = Workout.query.filter_by(user_id=user_id).order_by( - Workout.created_at.desc()).all() + workouts = Workout.query.filter_by(user_id=user_id).order_by( + Workout.created_at.desc()).all() for workout in workouts: diff --git a/templates/partials/workouts_list_fragment.html b/templates/partials/workouts_list_fragment.html index a1c20ec..7e56828 100644 --- a/templates/partials/workouts_list_fragment.html +++ b/templates/partials/workouts_list_fragment.html @@ -57,8 +57,8 @@