mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Update the nightly task that send performance platform statistics to use ft_notification_status rather than notification_history.
The previous query was including all notifications regardless of notification_status. I don't think that's right, it shouldn't include things like technical-failure or validation-failed. Thoughts? I also need to remove the query that's no longer being used.
This commit is contained in:
@@ -394,3 +394,15 @@ def fetch_monthly_template_usage_for_service(start_date, end_date, service_id):
|
||||
else:
|
||||
query = stats
|
||||
return query.all()
|
||||
|
||||
|
||||
def get_total_sent_notifications_for_day_and_type(day, notification_type):
|
||||
result = db.session.query(
|
||||
func.sum(FactNotificationStatus.notification_count).label('count')
|
||||
).filter(
|
||||
FactNotificationStatus.notification_type == notification_type,
|
||||
FactNotificationStatus.key_type != KEY_TYPE_TEST,
|
||||
FactNotificationStatus.bst_date == day,
|
||||
).scalar()
|
||||
|
||||
return result or 0
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from app import performance_platform_client
|
||||
from app.dao.notifications_dao import get_total_sent_notifications_in_date_range
|
||||
from app.utils import get_london_midnight_in_utc
|
||||
from app.dao.fact_notification_status_dao import get_total_sent_notifications_for_day_and_type
|
||||
|
||||
|
||||
def send_total_notifications_sent_for_day_stats(date, notification_type, count):
|
||||
@@ -18,15 +15,12 @@ def send_total_notifications_sent_for_day_stats(date, notification_type, count):
|
||||
|
||||
|
||||
def get_total_sent_notifications_for_day(day):
|
||||
start_date = get_london_midnight_in_utc(day)
|
||||
end_date = start_date + timedelta(days=1)
|
||||
|
||||
email_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'email')
|
||||
sms_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'sms')
|
||||
letter_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'letter')
|
||||
email_count = get_total_sent_notifications_for_day_and_type(day, 'email')
|
||||
sms_count = get_total_sent_notifications_for_day_and_type(day, 'sms')
|
||||
letter_count = get_total_sent_notifications_for_day_and_type(day, 'letter')
|
||||
|
||||
return {
|
||||
"start_date": start_date,
|
||||
"start_date": day,
|
||||
"email": {
|
||||
"count": email_count
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user