From fe01b2ade302cf6ba616ef72055f5361e7b45b9c Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sat, 9 Dec 2023 23:30:22 +1100 Subject: [PATCH] Statically render svg graphs on person view as well --- db.py | 5 +++-- templates/person.html | 9 ++------- utils.py | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/db.py b/db.py index 4227c40..d07df51 100644 --- a/db.py +++ b/db.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse from flask import g -from utils import get_all_exercises_from_topsets, get_exercise_graph_model, get_stats_from_topsets, get_workouts +from utils import get_all_exercises_from_topsets, get_exercise_graph_model, get_stats_from_topsets, get_topsets_for_person, get_workouts class DataBase(): @@ -192,7 +192,8 @@ class DataBase(): 'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'), 'Stats': get_stats_from_topsets(topsets), 'Exercises': get_all_exercises_from_topsets(topsets), - 'Workouts': get_workouts(topsets) + 'Workouts': get_workouts(topsets), + 'ExerciseProgressGraphs': get_topsets_for_person(topsets) } def get_workout(self, person_id, workout_id): diff --git a/templates/person.html b/templates/person.html index 1296ffd..3b00e1a 100644 --- a/templates/person.html +++ b/templates/person.html @@ -163,13 +163,8 @@
- {% for exercise_id in selected_exercise_ids %} -
- -
+ {% for graph in person['ExerciseProgressGraphs'] %} + {{ render_partial('partials/sparkline.html', **graph['ExerciseProgressGraph']) }} {% endfor %}
diff --git a/utils.py b/utils.py index a2cfd0b..7f59d3f 100644 --- a/utils.py +++ b/utils.py @@ -271,7 +271,7 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da # Generate points along the line of best fit y_best_fit = [m * xi + b for xi in x] best_fit_points = list(zip(y_best_fit, relative_positions)) - except np.linalg.LinAlgError: + except: pass # Create messages and zip data for SVG plotting