Switch to using custom svg sparkline for exercise graphs on person view, this isnt a proper implementation as it separate requests for each exercise selected (Want to get rid of dependency on plotly)

This commit is contained in:
Peter Stockings
2023-12-09 14:42:33 +11:00
parent 9d5d3b4507
commit e3435df8b5
3 changed files with 21 additions and 109 deletions

15
db.py
View File

@@ -464,7 +464,7 @@ class DataBase():
'SELECT exercise_id, name FROM exercise')
return exercises
def get_exercise_progress_for_user(self, person_id, exercise_id):
def get_exercise_progress_for_user(self, person_id, exercise_id, min_date=None, max_date=None):
# Execute SQL query to fetch topset data for a specific person and exercise
topsets = self.execute("""
SELECT
@@ -479,10 +479,13 @@ class DataBase():
JOIN
workout W ON T.workout_id = W.workout_id
WHERE
W.person_id = %s AND E.exercise_id = %s
W.person_id = %s
AND E.exercise_id = %s AND
(%s IS NULL OR W.start_date >= %s) AND
(%s IS NULL OR W.start_date <= %s)
ORDER BY
W.start_date;
""", [person_id, exercise_id])
""", [person_id, exercise_id, min_date, min_date, max_date, max_date])
# Return None if no topsets found
if not topsets:
@@ -500,9 +503,9 @@ class DataBase():
# Calculate viewBox dimensions
date_range = max_date - min_date
e1rm_range = max_e1rm - min_e1rm
reps_range = max_reps - min_reps
weight_range = max_weight - min_weight
e1rm_range = (max_e1rm - min_e1rm) or 1
reps_range = (max_reps - min_reps) or 1
weight_range = (max_weight - min_weight) or 1
vb_width, vb_height = date_range.days, e1rm_range
vb_width *= 200 / vb_width # Scale to 200px width
vb_height *= 75 / vb_height # Scale to 75px height