mirror of https://github.com/snachodog/mybuddy.git
Use floats for Diaper Change type data to prevent division issues in Python 2.7.
This commit is contained in:
parent
5194e80eb1
commit
880d7ca19f
|
@ -14,14 +14,14 @@
|
||||||
{% if info.wet_pct > 0 %}
|
{% if info.wet_pct > 0 %}
|
||||||
<div class="progress-bar bg-primary lead"
|
<div class="progress-bar bg-primary lead"
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
style="width: {{ info.wet_pct }}%;">{{ info.wet }} wet</div>
|
style="width: {{ info.wet_pct }}%;">{{ info.wet|floatformat:'0' }} wet</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if info.solid_pct > 0 %}
|
{% if info.solid_pct > 0 %}
|
||||||
<div class="progress-bar bg-secondary lead"
|
<div class="progress-bar bg-secondary lead"
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
style="width: {{ info.solid_pct }}%;">
|
style="width: {{ info.solid_pct }}%;">
|
||||||
<strong>{{ info.solid }}</strong> solid</div>
|
<strong>{{ info.solid|floatformat:'0' }}</strong> solid</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center text-light small">
|
<div class="text-center text-light small">
|
||||||
|
|
|
@ -45,7 +45,7 @@ def card_diaperchange_types(child, date=None):
|
||||||
hour=0, minute=0, second=0)
|
hour=0, minute=0, second=0)
|
||||||
|
|
||||||
for x in range(7):
|
for x in range(7):
|
||||||
stats[x] = {'wet': 0, 'solid': 0}
|
stats[x] = {'wet': 0.0, 'solid': 0.0}
|
||||||
|
|
||||||
instances = models.DiaperChange.objects.filter(child=child) \
|
instances = models.DiaperChange.objects.filter(child=child) \
|
||||||
.filter(time__gt=min_date).filter(time__lt=max_date).order_by('-time')
|
.filter(time__gt=min_date).filter(time__lt=max_date).order_by('-time')
|
||||||
|
@ -213,7 +213,7 @@ def _diaperchange_statistics(child):
|
||||||
changes = {
|
changes = {
|
||||||
'btwn_total': timezone.timedelta(0),
|
'btwn_total': timezone.timedelta(0),
|
||||||
'btwn_count': instances.count() - 1,
|
'btwn_count': instances.count() - 1,
|
||||||
'btwn_average': 0}
|
'btwn_average': 0.0}
|
||||||
last_instance = None
|
last_instance = None
|
||||||
|
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
|
@ -237,7 +237,7 @@ def _feeding_statistics(child):
|
||||||
feedings = {
|
feedings = {
|
||||||
'btwn_total': timezone.timedelta(0),
|
'btwn_total': timezone.timedelta(0),
|
||||||
'btwn_count': instances.count() - 1,
|
'btwn_count': instances.count() - 1,
|
||||||
'btwn_average': 0}
|
'btwn_average': 0.0}
|
||||||
last_instance = None
|
last_instance = None
|
||||||
|
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
|
@ -262,8 +262,8 @@ def _nap_statistics(child):
|
||||||
naps = {
|
naps = {
|
||||||
'total': instances.aggregate(Sum('duration'))['duration__sum'],
|
'total': instances.aggregate(Sum('duration'))['duration__sum'],
|
||||||
'count': instances.count(),
|
'count': instances.count(),
|
||||||
'average': 0,
|
'average': 0.0,
|
||||||
'avg_per_day': 0}
|
'avg_per_day': 0.0}
|
||||||
if naps['count'] > 0:
|
if naps['count'] > 0:
|
||||||
naps['average'] = naps['total'] / naps['count']
|
naps['average'] = naps['total'] / naps['count']
|
||||||
|
|
||||||
|
@ -285,10 +285,10 @@ def _sleep_statistics(child):
|
||||||
sleep = {
|
sleep = {
|
||||||
'total': instances.aggregate(Sum('duration'))['duration__sum'],
|
'total': instances.aggregate(Sum('duration'))['duration__sum'],
|
||||||
'count': instances.count(),
|
'count': instances.count(),
|
||||||
'average': 0,
|
'average': 0.0,
|
||||||
'btwn_total': timezone.timedelta(0),
|
'btwn_total': timezone.timedelta(0),
|
||||||
'btwn_count': instances.count() - 1,
|
'btwn_count': instances.count() - 1,
|
||||||
'btwn_average': 0}
|
'btwn_average': 0.0}
|
||||||
|
|
||||||
last_instance = None
|
last_instance = None
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
|
@ -310,7 +310,7 @@ def _weight_statistics(child):
|
||||||
:param child: an instance of the Child model.
|
:param child: an instance of the Child model.
|
||||||
:returns: a dictionary of statistics.
|
:returns: a dictionary of statistics.
|
||||||
"""
|
"""
|
||||||
weight = {'change_weekly': 0}
|
weight = {'change_weekly': 0.0}
|
||||||
|
|
||||||
instances = models.Weight.objects.filter(child=child).order_by('-date')
|
instances = models.Weight.objects.filter(child=child).order_by('-date')
|
||||||
newest = instances.first()
|
newest = instances.first()
|
||||||
|
|
Loading…
Reference in New Issue