Show exercise weekly/monthly progress on exercise history table
This commit is contained in:
@@ -303,6 +303,22 @@ def get_exercise_history(person_id, exercise_id):
|
|||||||
source_topset_id = request.args.get('source_topset_id', type=int)
|
source_topset_id = request.args.get('source_topset_id', type=int)
|
||||||
|
|
||||||
topsets = db.get_recent_topsets_for_exercise(person_id, exercise_id, limit, offset)
|
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',
|
return render_template('partials/exercise_history.html',
|
||||||
person_id=person_id,
|
person_id=person_id,
|
||||||
@@ -310,7 +326,11 @@ def get_exercise_history(person_id, exercise_id):
|
|||||||
topsets=topsets,
|
topsets=topsets,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
offset=offset,
|
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'])
|
@workout_bp.route("/person/<int:person_id>/workout/<int:workout_id>", methods=['GET'])
|
||||||
def show_workout(person_id, workout_id):
|
def show_workout(person_id, workout_id):
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
{% if offset == 0 %}
|
{% if offset == 0 %}
|
||||||
<div id="exercise-history-container"
|
<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">
|
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">
|
<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>
|
||||||
<div class="absolute right-0 z-10">
|
<div class="absolute right-0 z-10">
|
||||||
<button
|
<button
|
||||||
@@ -20,6 +23,13 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<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">
|
<thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-gray-700 dark:text-gray-400">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user