Embed achievement badges in exercise progress graphs

This commit is contained in:
Peter Stockings
2026-02-06 00:20:12 +11:00
parent 3f3725d277
commit a9f3dd4a38
2 changed files with 14 additions and 1 deletions

8
db.py
View File

@@ -427,6 +427,11 @@ class DataBase():
start_dates = [t['start_date'] for t in topsets] start_dates = [t['start_date'] for t in topsets]
messages = [f'{t["repetitions"]} x {t["weight"]}kg ({t["estimated_1rm"]}kg E1RM) on {t["start_date"].strftime("%d %b %y")}' for t in topsets] messages = [f'{t["repetitions"]} x {t["weight"]}kg ({t["estimated_1rm"]}kg E1RM) on {t["start_date"].strftime("%d %b %y")}' for t in topsets]
# Get the latest topset info for badges
latest_topset = topsets[-1]
latest_topset_id = latest_topset['topset_id']
latest_workout_id = latest_topset['workout_id']
exercise_progress = get_exercise_graph_model( exercise_progress = get_exercise_graph_model(
exercise_name, exercise_name,
estimated_1rm, estimated_1rm,
@@ -441,6 +446,9 @@ class DataBase():
max_date, max_date,
degree) degree)
exercise_progress['latest_topset_id'] = latest_topset_id
exercise_progress['latest_workout_id'] = latest_workout_id
return exercise_progress return exercise_progress
# Note fetching logic moved to routes/notes.py # Note fetching logic moved to routes/notes.py

View File

@@ -46,7 +46,12 @@
<div id="popover-{{ unique_id }}" class="absolute t-0 r-0 hidden bg-white border border-gray-300 p-2 z-10"> <div id="popover-{{ unique_id }}" class="absolute t-0 r-0 hidden bg-white border border-gray-300 p-2 z-10">
<!-- Popover content will be dynamically inserted here --> <!-- Popover content will be dynamically inserted here -->
</div> </div>
<h4 class="text-l font-semibold text-blue-400 text-center">{{ title }}</h4> <div class="flex items-center justify-center gap-2 mb-1">
<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>
<h2 class="text-xs font-semibold text-blue-200 mb-1 text-center"> <h2 class="text-xs font-semibold text-blue-200 mb-1 text-center">
{% if best_fit_formula %} {% if best_fit_formula %}
{{ best_fit_formula.kg_per_week }} kg/week, {{ best_fit_formula.kg_per_month }} kg/month {{ best_fit_formula.kg_per_week }} kg/week, {{ best_fit_formula.kg_per_month }} kg/month