From ff236ccc1e4bb6371611609c296a80b2dc286bd9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Dec 2024 11:17:51 -0400 Subject: [PATCH] fix(dashboard): update check to see if redis has today's data (#2017) * fix(dashboard): update check to see if redis has today's data * fix: update test for redis has no data --- app/main/views/dashboard.py | 2 +- tests/app/main/views/test_dashboard.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 54c141a82d..2c40d1a2a1 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -282,7 +282,7 @@ def aggregate_by_type(notification_data): todays_data = annual_limit_client.get_all_notification_counts(current_service.id) # if redis is empty, query the db - if todays_data is None: + if all(value == 0 for value in todays_data.values()): todays_data = service_api_client.get_service_statistics(service_id, limit_days=1, today_only=False) annual_data_aggregate = combine_daily_to_annual(todays_data, annual_data, "db") diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index e972baebe8..3be02e81d6 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1582,7 +1582,7 @@ def test_usage_report_aggregates_calculated_properly_without_redis( # mock annual_limit_client.get_all_notification_counts mocker.patch( "app.main.views.dashboard.annual_limit_client.get_all_notification_counts", - return_value=None, + return_value={"sms_delivered": 0, "email_delivered": 0, "sms_failed": 0, "email_failed": 0}, ) mocker.patch(