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:
Rebecca Law
2019-03-29 14:21:05 +00:00
parent 29df5730cb
commit 1806f092f3
5 changed files with 96 additions and 57 deletions

View File

@@ -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