From 47c89647665b4cb464136c11f55b0e11814512f6 Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Fri, 21 Jun 2024 16:58:09 -0600 Subject: [PATCH] fetch_notification_status_for_service_by_month altered to use NotificationAllTimeView like the other endpoints --- app/dao/fact_notification_status_dao.py | 22 +++++++++++----------- app/dao/services_dao.py | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/dao/fact_notification_status_dao.py b/app/dao/fact_notification_status_dao.py index 22c87fe83..f2769d2cd 100644 --- a/app/dao/fact_notification_status_dao.py +++ b/app/dao/fact_notification_status_dao.py @@ -84,21 +84,21 @@ def update_fact_notification_status(process_day, notification_type, service_id): def fetch_notification_status_for_service_by_month(start_date, end_date, service_id): return ( db.session.query( - func.date_trunc("month", FactNotificationStatus.local_date).label("month"), - FactNotificationStatus.notification_type, - FactNotificationStatus.notification_status, - func.sum(FactNotificationStatus.notification_count).label("count"), + func.date_trunc("month", NotificationAllTimeView.created_at).label("month"), + NotificationAllTimeView.notification_type, + NotificationAllTimeView.status.label('notification_status'), + func.count(NotificationAllTimeView.id).label("count"), ) .filter( - FactNotificationStatus.service_id == service_id, - FactNotificationStatus.local_date >= start_date, - FactNotificationStatus.local_date < end_date, - FactNotificationStatus.key_type != KeyType.TEST, + NotificationAllTimeView.service_id == service_id, + NotificationAllTimeView.created_at >= start_date, + NotificationAllTimeView.created_at < end_date, + NotificationAllTimeView.key_type != KeyType.TEST, ) .group_by( - func.date_trunc("month", FactNotificationStatus.local_date).label("month"), - FactNotificationStatus.notification_type, - FactNotificationStatus.notification_status, + func.date_trunc("month", NotificationAllTimeView.created_at).label("month"), + NotificationAllTimeView.notification_type, + NotificationAllTimeView.status, ) .all() ) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index dcf2536eb..74f8094a8 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -442,7 +442,7 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date): NotificationAllTimeView.service_id == service_id, NotificationAllTimeView.key_type != KeyType.TEST, NotificationAllTimeView.created_at >= start_date, - NotificationAllTimeView.created_at <= end_date, + NotificationAllTimeView.created_at < end_date, ) .group_by( NotificationAllTimeView.notification_type, @@ -470,7 +470,7 @@ def dao_fetch_stats_for_service_from_days_for_user( NotificationAllTimeView.service_id == service_id, NotificationAllTimeView.key_type != KeyType.TEST, NotificationAllTimeView.created_at >= start_date, - NotificationAllTimeView.created_at <= end_date, + NotificationAllTimeView.created_at < end_date, NotificationAllTimeView.created_by_id == user_id, ) .group_by(