Ensure naps are captured for both start and end time

This commit is contained in:
Christopher C. Wells 2020-06-09 07:01:44 -07:00
parent e2f432f92c
commit a09ceadc40
2 changed files with 25 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -150,7 +150,13 @@ def card_sleep_naps_day(child, date=None):
""" """
if not date: if not date:
date = timezone.localtime().date() date = timezone.localtime().date()
instances = models.Sleep.naps.filter(child=child, start__date=date) instances = models.Sleep.naps.filter(child=child).filter(
start__year=date.year,
start__month=date.month,
start__day=date.day) | models.Sleep.naps.filter(child=child).filter(
end__year=date.year,
end__month=date.month,
end__day=date.day)
return { return {
'type': 'sleep', 'type': 'sleep',
'total': instances.aggregate(Sum('duration'))['duration__sum'], 'total': instances.aggregate(Sum('duration'))['duration__sum'],