Skip to content

Commit

Permalink
fix #699, add diaper change count to card stats
Browse files Browse the repository at this point in the history
  • Loading branch information
josevh committed Dec 6, 2023
1 parent ce45180 commit b853f6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dashboard/templates/cards/diaperchange_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
3 changes: 2 additions & 1 deletion dashboard/templatetags/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit b853f6e

Please sign in to comment.