diff --git a/app.py b/app.py index fb21aee..139015e 100644 --- a/app.py +++ b/app.py @@ -434,7 +434,7 @@ def calculate_relative_positions(start_dates): def get_exercise_progress_for_user(person_id, exercise_id): width = request.args.get('width', 300, type=int) height = request.args.get('height', 100, type=int) - (estimated_1rm, start_dates) = db.get_exercise_progress_for_user(person_id, exercise_id) + (estimated_1rm, start_dates, messages) = db.get_exercise_progress_for_user(person_id, exercise_id) # Calculate vb_width min_date = min(start_dates) @@ -460,7 +460,7 @@ def get_exercise_progress_for_user(person_id, exercise_id): estimated_1rm = [((value - min_value) / value_range) * vb_height for value in estimated_1rm] relative_positions = calculate_relative_positions(start_dates) - data_points = list(zip(estimated_1rm, relative_positions)) + data_points = list(zip(estimated_1rm, relative_positions, messages)) return render_template('partials/sparkline.html', title="GHR", vb_width=vb_width, vb_height=vb_height, data_points=data_points) diff --git a/db.py b/db.py index 13f0cee..0830861 100644 --- a/db.py +++ b/db.py @@ -489,4 +489,7 @@ class DataBase(): estimated_1rm = [t['estimated_1rm'] for t in topsets] # Get a list of all start_dates start_dates = [t['start_date'] for t in topsets] - return (estimated_1rm, start_dates) \ No newline at end of file + # Create a list of messages with the structure 'estimated_1rm kg on start_date' with start_date formatted as 'dd/mm/yyyy' + messages = [f'{t["estimated_1rm"]}kg on {t["start_date"].strftime("%d/%m/%Y")}' for t in topsets] + + return (estimated_1rm, start_dates, messages) \ No newline at end of file diff --git a/templates/partials/sparkline.html b/templates/partials/sparkline.html index b7be7a2..e6077cf 100644 --- a/templates/partials/sparkline.html +++ b/templates/partials/sparkline.html @@ -4,7 +4,7 @@ {% set margin = 0 %} {# space allocated for axis labels and ticks #} {% macro path(data_points, vb_height) %} - {% for value, position in data_points %} + {% for value, position, message in data_points %} {% set x = position * vb_width %} {% set y = vb_height - value %} {% if loop.first %}M{{ x }} {{ y }}{% else %} L{{ x }} {{ y }}{% endif %} @@ -12,10 +12,10 @@ {% endmacro %} {% macro circles(data_points, vb_height) %} - {% for value, position in data_points %} + {% for value, position, message in data_points %} {% set x = position * vb_width %} {% set y = vb_height - value %} - + {{ circles(data_points, vb_height) }} + + - \ No newline at end of file