mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Removed/replaced retention redis count with notification count from db call
This commit is contained in:
committed by
Carlo Costino
parent
246e23f193
commit
a346a734fc
@@ -1,8 +1,7 @@
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
|
||||
from app.dao.date_util import get_months_for_financial_year
|
||||
from app.models import NOTIFICATION_STATUS_TYPES, NOTIFICATION_TYPES
|
||||
from app.models import NOTIFICATION_TYPES
|
||||
|
||||
|
||||
def format_statistics(statistics):
|
||||
@@ -55,26 +54,6 @@ def create_stats_dict():
|
||||
return stats_dict
|
||||
|
||||
|
||||
def format_monthly_template_notification_stats(year, rows):
|
||||
stats = {
|
||||
datetime.strftime(date, "%Y-%m"): {}
|
||||
for date in [datetime(year, month, 1) for month in range(4, 13)]
|
||||
+ [datetime(year + 1, month, 1) for month in range(1, 4)]
|
||||
}
|
||||
|
||||
for row in rows:
|
||||
formatted_month = row.month.strftime("%Y-%m")
|
||||
if str(row.template_id) not in stats[formatted_month]:
|
||||
stats[formatted_month][str(row.template_id)] = {
|
||||
"name": row.name,
|
||||
"type": row.template_type,
|
||||
"counts": dict.fromkeys(NOTIFICATION_STATUS_TYPES, 0),
|
||||
}
|
||||
stats[formatted_month][str(row.template_id)]["counts"][row.status] += row.count
|
||||
|
||||
return stats
|
||||
|
||||
|
||||
def create_zeroed_stats_dicts():
|
||||
return {
|
||||
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
|
||||
|
||||
Reference in New Issue
Block a user