Add options to filter epoch for exercise progress graphs (1M, 3M, 6M, All), however if there isnt data in a selected epoch the endpoint returns 404. Havent bothered to look into to it, probs should clean up code as well
This commit is contained in:
13
utils.py
13
utils.py
@@ -52,8 +52,11 @@ def get_topsets_for_person(person_topsets):
|
||||
weight = [t['Weight'] for t in exercise_topsets]
|
||||
start_dates = [t['StartDate'] for t in exercise_topsets]
|
||||
messages = [f'{t["Repetitions"]} x {t["Weight"]}kg ({t["Estimated1RM"]}kg E1RM) on {t["StartDate"].strftime("%d %b %y")}' for t in exercise_topsets]
|
||||
epoch = 'All'
|
||||
person_id = exercise_topsets[0]['PersonId']
|
||||
exercise_id = exercise_topsets[0]['ExerciseId']
|
||||
|
||||
exercise_progress = get_exercise_graph_model(exercise_topsets[0]['ExerciseName'], estimated_1rm, repetitions, weight, start_dates, messages)
|
||||
exercise_progress = get_exercise_graph_model(exercise_topsets[0]['ExerciseName'], estimated_1rm, repetitions, weight, start_dates, messages, epoch, person_id, exercise_id)
|
||||
|
||||
exercises_topsets.append({
|
||||
'ExerciseId': e['ExerciseId'],
|
||||
@@ -236,7 +239,7 @@ def get_date_info(input_date, selected_view):
|
||||
'end_date': last_day_of_year,
|
||||
}
|
||||
|
||||
def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_dates, messages):
|
||||
def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_dates, messages, epoch, person_id, exercise_id):
|
||||
min_date, max_date = min(start_dates), max(start_dates)
|
||||
min_e1rm, max_e1rm = min(estimated_1rm), max(estimated_1rm)
|
||||
min_reps, max_reps = min(repetitions), max(repetitions)
|
||||
@@ -318,7 +321,11 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
'plots': [repetitions, weight, estimated_1rm],
|
||||
'best_fit_points': best_fit_points,
|
||||
'best_fit_formula': best_fit_formula,
|
||||
'plot_labels': plot_labels
|
||||
'plot_labels': plot_labels,
|
||||
'epochs': ['1M', '3M', '6M', 'All'],
|
||||
'selected_epoch': epoch,
|
||||
'person_id': person_id,
|
||||
'exercise_id': exercise_id
|
||||
}
|
||||
|
||||
def get_workout_counts(workouts, period='week'):
|
||||
|
||||
Reference in New Issue
Block a user