On dashboard display list of sets in descending order (start_date) with E1RM
This commit is contained in:
9
app.py
9
app.py
@@ -124,14 +124,9 @@ def get_calendar(person_id):
|
||||
# selected_view = month | year | all
|
||||
date_info = get_date_info(selected_date, selected_view)
|
||||
|
||||
next_date = date_info['next_date']
|
||||
previous_date = date_info['previous_date']
|
||||
start_date = date_info['start_date']
|
||||
end_date = date_info['end_date']
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'calendar.html', 'content', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month)
|
||||
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month)
|
||||
return render_block(app.jinja_env, 'calendar.html', 'content', person=person, selected_date=selected_date, selected_view=selected_view, **date_info, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month)
|
||||
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, **date_info, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month)
|
||||
|
||||
|
||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/modal", methods=['GET'])
|
||||
|
||||
@@ -127,11 +127,11 @@
|
||||
{% endif %}
|
||||
|
||||
{% for e in p['Exercises'] %}
|
||||
{% if e['Topsets']|length > 1 %}
|
||||
<div class="flex flex-col mt-8">
|
||||
<div class="overflow-x-auto rounded-lg">
|
||||
<div class="align-middle inline-block min-w-full">
|
||||
<div class="shadow overflow-hidden sm:rounded-lg">
|
||||
{% if e['RepMaxes']|length > 1 %}
|
||||
<div class="w-full mt-2 pb-2 aspect-video">
|
||||
<div class="hidden"
|
||||
hx-get="{{ url_for('get_exercise_progress_for_user', person_id=p['PersonId'], exercise_id=e['ExerciseId'], min_date=min_date, max_date=max_date) }}"
|
||||
@@ -139,7 +139,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
@@ -149,13 +148,17 @@
|
||||
</th>
|
||||
<th scope="col"
|
||||
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Rep Max
|
||||
Set
|
||||
</th>
|
||||
<th scope="col"
|
||||
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
E1RM
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white">
|
||||
|
||||
{% for rm in e['RepMaxes'] %}
|
||||
{% for rm in e['Topsets'] %}
|
||||
<tr>
|
||||
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
|
||||
{{ rm['StartDate'] }}
|
||||
@@ -163,15 +166,20 @@
|
||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
||||
{{ rm['Repetitions'] }} x {{ rm['Weight'] }}kg
|
||||
</td>
|
||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
||||
{{ rm['Estimated1RM'] }}kg
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
36
utils.py
36
utils.py
@@ -34,38 +34,24 @@ def get_all_exercises_from_topsets(topsets):
|
||||
})
|
||||
return exercises
|
||||
|
||||
|
||||
def get_rep_maxes_for_person(person_topsets):
|
||||
def get_topsets_for_person(person_topsets):
|
||||
person_exercises = get_all_exercises_from_topsets(person_topsets)
|
||||
|
||||
rep_maxes_in_exercises = []
|
||||
exercises_topsets = []
|
||||
for e in person_exercises:
|
||||
exercise_topsets = [
|
||||
t for t in person_topsets if t['ExerciseId'] == e['ExerciseId']]
|
||||
set_reps = set([t['Repetitions'] for t in exercise_topsets])
|
||||
exercise_topsets = [t for t in person_topsets if t['ExerciseId'] == e['ExerciseId']]
|
||||
|
||||
topsets_for_exercise = []
|
||||
for rep in set_reps:
|
||||
reps = [t for t in exercise_topsets if t['Repetitions'] == rep]
|
||||
max_weight = max([t['Weight'] for t in reps])
|
||||
max_topset_for_rep = [t for t in reps if t['Weight'] == max_weight]
|
||||
topsets_for_exercise.append({
|
||||
'StartDate': max_topset_for_rep[0]['StartDate'].strftime("%b %d %Y"),
|
||||
'Repetitions': rep,
|
||||
'Weight': max_weight,
|
||||
'Estimated1RM': max_topset_for_rep[0]['Estimated1RM'],
|
||||
})
|
||||
# Sort topsets by StartDate in descending order
|
||||
sorted_topsets = sorted(exercise_topsets, key=lambda x: x['StartDate'], reverse=True)
|
||||
|
||||
# datetime.strptime(x['StartDate'], "%Y-%m-%d")
|
||||
topsets_for_exercise.sort(
|
||||
key=lambda x: x['Repetitions'], reverse=True)
|
||||
|
||||
rep_maxes_in_exercises.append({
|
||||
exercises_topsets.append({
|
||||
'ExerciseId': e['ExerciseId'],
|
||||
'ExerciseName': e['ExerciseName'],
|
||||
'RepMaxes': topsets_for_exercise
|
||||
'Topsets': sorted_topsets
|
||||
})
|
||||
return rep_maxes_in_exercises
|
||||
|
||||
return exercises_topsets
|
||||
|
||||
|
||||
|
||||
def get_people_and_exercise_rep_maxes(topsets, selected_person_ids, selected_exercise_ids, min_date, max_date):
|
||||
@@ -84,7 +70,7 @@ def get_people_and_exercise_rep_maxes(topsets, selected_person_ids, selected_exe
|
||||
'PersonId': person_id,
|
||||
'PersonName': workouts_for_person[0]['PersonName'],
|
||||
'NumberOfWorkouts': len(list(set([t['WorkoutId'] for t in workouts_for_person if t['WorkoutId'] is not None]))),
|
||||
'Exercises': get_rep_maxes_for_person(workouts_for_person)
|
||||
'Exercises': get_topsets_for_person(workouts_for_person)
|
||||
})
|
||||
return {"People": people, "Stats": get_stats_from_topsets(topsets)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user