Update periodical report with well being informations

This commit is contained in:
Gregory Trullemans 2023-07-05 12:27:23 +02:00
parent 3c38b5b168
commit e070130cec
2 changed files with 44 additions and 8 deletions

View File

@ -60,7 +60,7 @@
<div class="row">
<div class="col-4">
<h4 class="mb-1">Physiological</h4>
{% if mindstate_score.mean_mindstate_value or height_weight_value.mean_height_value %}
{% if wellbeing_score.mean_mindstate_value or height_weight_value.mean_height_value %}
<table class="table">
<thead>
<th class="pt-0 pb-0"></th>
@ -68,12 +68,36 @@
<th class="pt-0 pb-0 text-right">Average</th>
<th class="pt-0 pb-0 text-right">Max</th>
</thead>
{% if mindstate_score %}
{% if wellbeing_score %}
<tr>
<td class="pt-0 pb-0"><b>Mind state</b></td>
<td class="pt-0 pb-0 text-right">{{ mindstate_score.min_mindstate_value }}</td>
<td class="pt-0 pb-0 text-right">{{ mindstate_score.mean_mindstate_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ mindstate_score.max_mindstate_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.min_mindstate_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.mean_mindstate_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.max_mindstate_value }}</td>
</tr>
<tr>
<td class="pt-0 pb-0"><b>Sleep</b></td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.min_sleep_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.mean_sleep_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.max_sleep_value }}</td>
</tr>
<tr>
<td class="pt-0 pb-0"><b>Stress</b></td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.min_stress_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.mean_stress_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.max_stress_value }}</td>
</tr>
<tr>
<td class="pt-0 pb-0"><b>Fatigue</b></td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.min_fatigue_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.mean_fatigue_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.max_fatigue_value }}</td>
</tr>
<tr>
<td class="pt-0 pb-0"><b>Muscle soreness</b></td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.min_muscle_soreness_value }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.mean_muscle_soreness_value|stringformat:".1f" }}</td>
<td class="pt-0 pb-0 text-right">{{ wellbeing_score.max_muscle_soreness_value }}</td>
</tr>
{% endif %}
{% if height_weight_value.mean_height_value %}

View File

@ -954,13 +954,25 @@ def generate_report_for_period(
season_informations = gymnast.season_informations.filter(season=season).first()
# PHYSIOLOGICAL INFORMATIONS
# Mindstate Score
mindstate_score = gymnast.wellbeings.filter(
# WellBeing Score
wellbeing_score = gymnast.wellbeings.filter(
date__gte=date_begin, date__lte=date_end
).aggregate(
min_mindstate_value=Min("mindstate"),
mean_mindstate_value=Avg("mindstate"),
max_mindstate_value=Max("mindstate"),
min_sleep_value=Min("sleep"),
mean_sleep_value=Avg("sleep"),
max_sleep_value=Max("sleep"),
min_stress_value=Min("stress"),
mean_stress_value=Avg("stress"),
max_stress_value=Max("stress"),
min_fatigue_value=Min("fatigue"),
mean_fatigue_value=Avg("fatigue"),
max_fatigue_value=Max("fatigue"),
min_muscle_soreness_value=Min("muscle_soreness"),
mean_muscle_soreness_value=Avg("muscle_soreness"),
max_muscle_soreness_value=Max("muscle_soreness"),
)
height_weight_value = gymnast.height_weight.filter(
@ -1222,7 +1234,7 @@ def generate_report_for_period(
"gymnast": gymnast,
"season_informations": season_informations,
# MEDICAL INFORMATIONS
"mindstate_score": mindstate_score,
"wellbeing_score": wellbeing_score,
"height_weight_value": height_weight_value,
# INTENSITY
"intensity_value": intensity_value,