fix #699, add diaper change count to card stats

This commit is contained in:
Jose V. Herrera Gallegos 2023-12-06 11:46:51 -08:00 committed by Christopher Charbonneau Wells
parent 1063d39af0
commit 3131aeb328
2 changed files with 5 additions and 1 deletions

View File

@ -49,6 +49,9 @@
{% else %}
{% blocktrans with days_ago=key %}{{ days_ago }} days ago{% endblocktrans %}
{% endif %}
{% if info.changes > 0 %}
({{ info.changes|floatformat:'0' }} {% trans "changes" %})
{% endif %}
</div>
{% endif %}
{% endfor %}

View File

@ -70,7 +70,7 @@ def card_diaperchange_types(context, child, date=None):
)
for x in range(7):
stats[x] = {"wet": 0.0, "solid": 0.0, "empty": 0.0}
stats[x] = {"wet": 0.0, "solid": 0.0, "empty": 0.0, "changes": 0.0}
instances = (
models.DiaperChange.objects.filter(child=child)
@ -82,6 +82,7 @@ def card_diaperchange_types(context, child, date=None):
for instance in instances:
key = (max_date - instance.time).days
stats[key]["changes"] += 1
if instance.wet:
stats[key]["wet"] += 1
if instance.solid: