Statically render svg graphs on person view as well
This commit is contained in:
5
db.py
5
db.py
@@ -7,7 +7,7 @@ from urllib.parse import urlparse
|
|||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
|
||||||
from utils import get_all_exercises_from_topsets, get_exercise_graph_model, get_stats_from_topsets, get_workouts
|
from utils import get_all_exercises_from_topsets, get_exercise_graph_model, get_stats_from_topsets, get_topsets_for_person, get_workouts
|
||||||
|
|
||||||
|
|
||||||
class DataBase():
|
class DataBase():
|
||||||
@@ -192,7 +192,8 @@ class DataBase():
|
|||||||
'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'),
|
'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'),
|
||||||
'Stats': get_stats_from_topsets(topsets),
|
'Stats': get_stats_from_topsets(topsets),
|
||||||
'Exercises': get_all_exercises_from_topsets(topsets),
|
'Exercises': get_all_exercises_from_topsets(topsets),
|
||||||
'Workouts': get_workouts(topsets)
|
'Workouts': get_workouts(topsets),
|
||||||
|
'ExerciseProgressGraphs': get_topsets_for_person(topsets)
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_workout(self, person_id, workout_id):
|
def get_workout(self, person_id, workout_id):
|
||||||
|
|||||||
@@ -163,13 +163,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4 mb-4 w-full grid grid-cols-1 2xl:grid-cols-2 gap-4">
|
<div class="mt-4 mb-4 w-full grid grid-cols-1 2xl:grid-cols-2 gap-4">
|
||||||
{% for exercise_id in selected_exercise_ids %}
|
{% for graph in person['ExerciseProgressGraphs'] %}
|
||||||
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 ">
|
{{ render_partial('partials/sparkline.html', **graph['ExerciseProgressGraph']) }}
|
||||||
<div class="hidden"
|
|
||||||
hx-get="{{ url_for('get_exercise_progress_for_user', person_id=person['PersonId'], exercise_id=exercise_id, min_date=min_date, max_date=max_date) }}"
|
|
||||||
hx-trigger="load" hx-target="this" hx-swap="outerHTML">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
2
utils.py
2
utils.py
@@ -271,7 +271,7 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
|||||||
# Generate points along the line of best fit
|
# Generate points along the line of best fit
|
||||||
y_best_fit = [m * xi + b for xi in x]
|
y_best_fit = [m * xi + b for xi in x]
|
||||||
best_fit_points = list(zip(y_best_fit, relative_positions))
|
best_fit_points = list(zip(y_best_fit, relative_positions))
|
||||||
except np.linalg.LinAlgError:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create messages and zip data for SVG plotting
|
# Create messages and zip data for SVG plotting
|
||||||
|
|||||||
Reference in New Issue
Block a user