From 2655dc60cd49bea49fd8e1a061292accc27964a2 Mon Sep 17 00:00:00 2001 From: Cliff Hill Date: Tue, 6 Feb 2024 16:01:08 -0500 Subject: [PATCH] Stuff was done. Signed-off-by: Cliff Hill --- app/dao/fact_notification_status_dao.py | 14 +++++++++----- tests/app/dao/test_fact_notification_status_dao.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/dao/fact_notification_status_dao.py b/app/dao/fact_notification_status_dao.py index 0473bdc4c..286beebc2 100644 --- a/app/dao/fact_notification_status_dao.py +++ b/app/dao/fact_notification_status_dao.py @@ -195,7 +195,9 @@ def fetch_notification_status_for_service_for_today_and_7_previous_days( def fetch_notification_status_totals_for_all_services(start_date, end_date): stats = ( db.session.query( - FactNotificationStatus.notification_type.cast(db.Text).label("notification_type"), + FactNotificationStatus.notification_type.cast(db.Text).label( + "notification_type" + ), FactNotificationStatus.notification_status.cast(db.Text).label("status"), FactNotificationStatus.key_type.cast(db.Text).label("key_type"), func.sum(FactNotificationStatus.notification_count).label("count"), @@ -270,8 +272,10 @@ def fetch_stats_for_all_services_by_date_range( Service.restricted.label("restricted"), Service.active.label("active"), Service.created_at.label("created_at"), - FactNotificationStatus.notification_type.label("notification_type"), - FactNotificationStatus.notification_status.label("status"), + FactNotificationStatus.notification_type.cast(db.Text).label( + "notification_type" + ), + FactNotificationStatus.notification_status.cast(db.Text).label("status"), func.sum(FactNotificationStatus.notification_count).label("count"), ) .filter( @@ -321,8 +325,8 @@ def fetch_stats_for_all_services_by_date_range( Service.restricted.label("restricted"), Service.active.label("active"), Service.created_at.label("created_at"), - subquery.c.notification_type.label("notification_type"), - subquery.c.status.label("status"), + subquery.c.notification_type.cast(db.Text).label("notification_type"), + subquery.c.status.cast(db.Text).label("status"), subquery.c.count.label("count"), ).outerjoin(subquery, subquery.c.service_id == Service.id) diff --git a/tests/app/dao/test_fact_notification_status_dao.py b/tests/app/dao/test_fact_notification_status_dao.py index cd9c5bedd..e1606433e 100644 --- a/tests/app/dao/test_fact_notification_status_dao.py +++ b/tests/app/dao/test_fact_notification_status_dao.py @@ -857,7 +857,7 @@ def test_get_total_notifications_for_date_range(sample_service): ) assert len(results) == 1 - assert results[0] == ("2021-03-01", 15, 20) + assert results[0] == (date.fromisoformat("2021-03-01"), 15, 20) @pytest.mark.skip(reason="Need a better way to test variable DST date")