Show exercise weekly/monthly progress on exercise history table

This commit is contained in:
Peter Stockings
2026-02-26 23:53:47 +11:00
parent b31ab97cd4
commit 73e02a7b12
2 changed files with 33 additions and 3 deletions

View File

@@ -303,6 +303,22 @@ def get_exercise_history(person_id, exercise_id):
source_topset_id = request.args.get('source_topset_id', type=int)
topsets = db.get_recent_topsets_for_exercise(person_id, exercise_id, limit, offset)
title = "History"
best_fit_formula = None
latest_workout_id = None
latest_topset_id = None
if topsets:
# Fetch progress data to get title and best_fit_formula if there's history
exercise_progress = db.get_exercise_progress_for_user(
person_id, exercise_id, epoch='all')
if exercise_progress:
title = exercise_progress.get('title', "History")
best_fit_formula = exercise_progress.get('best_fit_formula')
latest_workout_id = exercise_progress.get('latest_workout_id')
latest_topset_id = exercise_progress.get('latest_topset_id')
return render_template('partials/exercise_history.html',
person_id=person_id,
@@ -310,7 +326,11 @@ def get_exercise_history(person_id, exercise_id):
topsets=topsets,
limit=limit,
offset=offset,
source_topset_id=source_topset_id)
source_topset_id=source_topset_id,
title=title,
best_fit_formula=best_fit_formula,
latest_workout_id=latest_workout_id,
latest_topset_id=latest_topset_id)
@workout_bp.route("/person/<int:person_id>/workout/<int:workout_id>", methods=['GET'])
def show_workout(person_id, workout_id):

View File

@@ -1,9 +1,12 @@
{% if offset == 0 %}
<div id="exercise-history-container"
class="w-full bg-gray-50 dark:bg-gray-800 p-4 border-t border-gray-200 dark:border-gray-700 shadow-inner overflow-x-auto">
<div class="flex items-center justify-between sm:justify-center relative mb-4">
<div class="flex items-center justify-between sm:justify-center relative mb-1">
<div class="flex items-center justify-center gap-2 w-full">
<h4 class="text-sm font-semibold text-gray-900 dark:text-white">History</h4>
<h4 class="text-l font-semibold text-blue-400">{{ title }}</h4>
<div hx-get="{{ url_for('workout.get_topset_achievements', person_id=person_id, workout_id=latest_workout_id, topset_id=latest_topset_id) }}"
hx-trigger="load" hx-target="this" hx-swap="innerHTML" class="flex items-center">
</div>
</div>
<div class="absolute right-0 z-10">
<button
@@ -20,6 +23,13 @@
</button>
</div>
</div>
{% if best_fit_formula %}
<h2 class="text-xs font-semibold text-blue-200 mb-4 text-center">
{{ best_fit_formula.kg_per_week }} kg/week, {{ best_fit_formula.kg_per_month }} kg/month
</h2>
{% else %}
<div class="mb-4"></div>
{% endif %}
<table class="w-full text-left text-sm text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-gray-700 dark:text-gray-400">
<tr>