Add support to set degree of line of best fit for exercise progress graphs in custom view

This commit is contained in:
Peter Stockings
2025-02-06 23:43:10 +11:00
parent 116de33df3
commit 39e91f2655
4 changed files with 145 additions and 52 deletions

3
app.py
View File

@@ -404,11 +404,12 @@ def get_exercise_progress_for_user(person_id, exercise_id):
max_date = convert_str_to_date(request.args.get(
'max_date'), '%Y-%m-%d')
epoch = request.args.get('epoch', default='All')
degree = request.args.get('degree', type=int, default=1)
if epoch == 'Custom' and (min_date is None or max_date is None):
(min_date, max_date) = db.get_exercise_earliest_and_latest_dates(person_id, exercise_id)
exercise_progress = db.get_exercise_progress_for_user(person_id, exercise_id, min_date, max_date, epoch)
exercise_progress = db.get_exercise_progress_for_user(person_id, exercise_id, min_date, max_date, epoch, degree=degree)
if not exercise_progress:
abort(404)