Remove graph model data from dashboard/people endpoints
This commit is contained in:
37
app.py
37
app.py
@@ -85,8 +85,6 @@ def get_person(person_id):
|
||||
max_date = request.args.get(
|
||||
'max_date', default=max_date, type=convert_str_to_date)
|
||||
|
||||
graph_axis = request.args.getlist('graph_axis')
|
||||
|
||||
selected_exercise_ids = request.args.getlist('exercise_id', type=int)
|
||||
all_exercise_ids_for_person = [e['ExerciseId']
|
||||
for e in person['Exercises']]
|
||||
@@ -105,41 +103,10 @@ def get_person(person_id):
|
||||
lambda e: e['ExerciseId'] in selected_exercise_ids, person['Exercises'])
|
||||
person['FilteredExercises'] = list(filtered_exercises)
|
||||
|
||||
if graph_axis:
|
||||
# New feature to plot reps and weights over time
|
||||
topsets_with_start_date = flatten([(p['StartDate'], p['TopSets'])
|
||||
for p in person['Workouts']])
|
||||
topsets = flatten([[{**t, 'StartDate': start_date} for t in topsets]
|
||||
for (start_date, topsets) in topsets_with_start_date])
|
||||
|
||||
exercise_graph_view_models = []
|
||||
for exercise_id in selected_exercise_ids:
|
||||
topsets_for_exercise = [
|
||||
t for t in topsets if t['ExerciseId'] == exercise_id]
|
||||
if topsets_for_exercise:
|
||||
repitions = [t['Repetitions'] for t in topsets_for_exercise]
|
||||
weights = [t['Weight'] for t in topsets_for_exercise]
|
||||
estimated_one_rep_max = [t['Estimated1RM']
|
||||
for t in topsets_for_exercise]
|
||||
start_dates = [t['StartDate'].strftime(
|
||||
"%Y-%m-%d") for t in topsets_for_exercise]
|
||||
exercise_view_model = {
|
||||
'ExerciseId': exercise_id,
|
||||
'ExerciseName': topsets_for_exercise[0]['ExerciseName'],
|
||||
'Repetitions': repitions[::-1],
|
||||
'Weights': weights[::-1],
|
||||
'Estimated1RM': estimated_one_rep_max[::-1],
|
||||
'StartDates': start_dates[::-1]
|
||||
}
|
||||
exercise_graph_view_models.append(exercise_view_model)
|
||||
person['ExerciseGraphs'] = exercise_graph_view_models
|
||||
else:
|
||||
person['ExerciseGraphs'] = []
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'person.html', 'content', person=person, selected_exercise_ids=selected_exercise_ids, max_date=max_date, min_date=min_date, tags=tags, graph_axis=graph_axis), 200, {"HX-Trigger": "updatedPeople"}
|
||||
return render_block(app.jinja_env, 'person.html', 'content', person=person, selected_exercise_ids=selected_exercise_ids, max_date=max_date, min_date=min_date, tags=tags), 200, {"HX-Trigger": "updatedPeople"}
|
||||
|
||||
return render_template('person.html', person=person, selected_exercise_ids=selected_exercise_ids, max_date=max_date, min_date=min_date, tags=tags, graph_axis=graph_axis), 200, {"HX-Trigger": "updatedPeople"}
|
||||
return render_template('person.html', person=person, selected_exercise_ids=selected_exercise_ids, max_date=max_date, min_date=min_date, tags=tags), 200, {"HX-Trigger": "updatedPeople"}
|
||||
|
||||
|
||||
@ app.route("/person/<int:person_id>/calendar")
|
||||
|
||||
Reference in New Issue
Block a user