Add min/max filter filter for exercise sparkline graph
This commit is contained in:
28
db.py
28
db.py
@@ -494,7 +494,7 @@ class DataBase():
|
||||
start_dates = [t['start_date'] for t in topsets]
|
||||
messages = [f'{t["repetitions"]} x {t["weight"]}kg ({t["estimated_1rm"]}kg E1RM) on {t["start_date"].strftime("%d %b %y")}' for t in topsets]
|
||||
|
||||
exercise_progress = get_exercise_graph_model(topsets[0]['exercise_name'], estimated_1rm, repetitions, weight, start_dates, messages, epoch, person_id, exercise_id)
|
||||
exercise_progress = get_exercise_graph_model(topsets[0]['exercise_name'], estimated_1rm, repetitions, weight, start_dates, messages, epoch, person_id, exercise_id, min_date, max_date)
|
||||
|
||||
return exercise_progress
|
||||
|
||||
@@ -546,4 +546,30 @@ class DataBase():
|
||||
|
||||
# Return a tuple containing the person's name and their workout notes
|
||||
return (person_name, workout_notes_list)
|
||||
|
||||
def get_exercise_earliest_and_latest_dates(self, person_id, exercise_id):
|
||||
sql_query = """
|
||||
SELECT
|
||||
w.start_date
|
||||
FROM workout w
|
||||
INNER JOIN topset t on w.workout_id = t.workout_id
|
||||
INNER JOIN exercise e on t.exercise_id = e.exercise_id
|
||||
WHERE w.person_id = %s AND e.exercise_id = %s
|
||||
ORDER BY w.start_date DESC;
|
||||
"""
|
||||
|
||||
# Execute the SQL query
|
||||
workout_exercise_dates = self.execute(sql_query, [person_id, exercise_id])
|
||||
|
||||
if not workout_exercise_dates:
|
||||
return None, None
|
||||
|
||||
latest_date = workout_exercise_dates[0]['start_date']
|
||||
earliest_date = workout_exercise_dates[-1]['start_date']
|
||||
|
||||
return earliest_date, latest_date
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user