diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index f480b4852..09322a464 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -480,7 +480,7 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date): # Query for daily total notifications total_stmt = select( - func.date_trunc("day", total_substmt.c.day).label("day"), + total_substmt.c.day, func.sum(total_substmt.c.notification_count).label("total_notifications"), ).group_by( total_substmt.c.day @@ -514,8 +514,6 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date): data = db.session.execute(stmt).all() - print("Daily Total Notifications:", total_notifications) - return total_notifications, data def dao_fetch_stats_for_service_from_days_for_user( diff --git a/app/enums.py b/app/enums.py index e69678671..37b3b6892 100644 --- a/app/enums.py +++ b/app/enums.py @@ -212,5 +212,3 @@ class StatisticsType(StrEnum): DELIVERED = "delivered" FAILURE = "failure" PENDING = "pending" - SENDING = "sending" - CREATED = "created" diff --git a/app/service/statistics.py b/app/service/statistics.py index 41ced13ec..a6d87da9f 100644 --- a/app/service/statistics.py +++ b/app/service/statistics.py @@ -29,7 +29,6 @@ def format_statistics(statistics, total_notifications=None): sms_dict = counts[NotificationType.SMS] delivered_count = sms_dict[StatisticsType.DELIVERED] failed_count = sms_dict[StatisticsType.FAILURE] - print('total_notifications',total_notifications) pending_count = total_notifications - (delivered_count + failed_count) pending_count = max(0, pending_count) @@ -102,20 +101,11 @@ def create_zeroed_stats_dicts(): def _update_statuses_from_row(update_dict, row): - requested_count = 0 - delivered_count = 0 - failed_count = 0 - - # Update requested count if row.status != NotificationStatus.CANCELLED: update_dict[StatisticsType.REQUESTED] += row.count - - # Update delivered count if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT): update_dict[StatisticsType.DELIVERED] += row.count - - # Update failure count - if row.status in ( + elif row.status in ( NotificationStatus.FAILED, NotificationStatus.TECHNICAL_FAILURE, NotificationStatus.TEMPORARY_FAILURE, @@ -124,7 +114,6 @@ def _update_statuses_from_row(update_dict, row): NotificationStatus.VIRUS_SCAN_FAILED, ): update_dict[StatisticsType.FAILURE] += row.count - failed_count += row.count def create_empty_monthly_notification_status_stats_dict(year):