This commit is contained in:
Benjamin Häublein 2020-03-16 18:53:36 +01:00
parent 853ab54b8c
commit aeba14f714
1 changed files with 11 additions and 8 deletions

View File

@ -240,15 +240,17 @@ def _feeding_statistics(child):
""" """
feedings = [ feedings = [
{ {
'start': timezone.now()-timezone.timedelta(days=3), 'start': timezone.now()-timezone.timedelta(days=3),
'title': _('Feeding frequency')+ " 3 "+_("days") 'title': _('Feeding frequency (past 3 days)')
},
{
'start': timezone.now()-timezone.timedelta(weeks=2),
'title': _('Feeding frequency') + " 2 "+_("weeks")
}, },
{ {
'start': timezone.make_aware(datetime.combine(date.min, time(0,0)) + timezone.timedelta(days=1) ), 'start': timezone.now()-timezone.timedelta(weeks=2),
'title': _('Feeding frequency (past 2 weeks)')
},
{
'start': timezone.make_aware(
datetime.combine(date.min, time(0, 0))
+ timezone.timedelta(days=1)),
'title': _('Feeding frequency') 'title': _('Feeding frequency')
} }
] ]
@ -264,7 +266,8 @@ def _feeding_statistics(child):
if last_instance: if last_instance:
for timespan in feedings: for timespan in feedings:
if last_instance.start > timespan['start']: if last_instance.start > timespan['start']:
timespan['btwn_total'] += instance.start - last_instance.end timespan['btwn_total'] += (instance.start
- last_instance.end)
timespan['btwn_count'] += 1 timespan['btwn_count'] += 1
last_instance = instance last_instance = instance