Merge pull request #144 from phardy/master

Ensure date passed to nap filter is localtime.
This commit is contained in:
Christopher Charbonneau Wells 2020-05-18 19:30:35 -07:00 committed by GitHub
commit e2f432f92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -148,8 +148,9 @@ def card_sleep_naps_day(child, date=None):
:param date: a Date object for the day to filter.
:returns: a dictionary of nap data statistics.
"""
date = timezone.localtime(date).astimezone(timezone.utc)
instances = models.Sleep.naps.filter(child=child, start__date=date.date())
if not date:
date = timezone.localtime().date()
instances = models.Sleep.naps.filter(child=child, start__date=date)
return {
'type': 'sleep',
'total': instances.aggregate(Sum('duration'))['duration__sum'],