diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index b9ad66ae9..867f103b3 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -267,13 +267,13 @@ def dao_fetch_monthly_historical_stats_for_service(service_id, year): ) months = { - datetime.strftime(date, '%Y-%m'): dict.fromkeys( - TEMPLATE_TYPES, - dict.fromkeys( + datetime.strftime(date, '%Y-%m'): { + template_type: dict.fromkeys( NOTIFICATION_STATUS_TYPES, 0 ) - ) + for template_type in TEMPLATE_TYPES + } for date in [ datetime(year, month, 1) for month in range(4, 13) ] + [ diff --git a/tests/app/dao/test_services_dao.py b/tests/app/dao/test_services_dao.py index af72342d0..6e4afa8b3 100644 --- a/tests/app/dao/test_services_dao.py +++ b/tests/app/dao/test_services_dao.py @@ -545,8 +545,8 @@ def test_fetch_monthly_historical_stats_separates_weeks(notify_db, notify_db_ses ('2017-03', 'created', 2), ): assert result[date]['sms'][status] == count - assert result[date]['email'][status] == count - assert result[date]['letter'][status] == count + assert result[date]['email'][status] == 0 + assert result[date]['letter'][status] == 0 assert result.keys() == { '2016-04', '2016-05', '2016-06',