Persist the processing time statistics to the database.

The performance platform is going away soon. The only stat that we do not have in our database is the processing time. Let me clarify the only statistic we don't have in our database that we can query efficiently is the processing time. Any queries on notification_history are too inefficient to use on a web page.
Processing time = the total number of normal/team emails and text messages plus the number of messages that have gone from created to sending within 10 seconds per whole day. We can then easily calculate the percentage of messages that were marked as sending under 10 seconds.
This commit is contained in:
Rebecca Law
2021-02-22 15:42:29 +00:00
parent 82e5a1804b
commit 21edf7bfdd
9 changed files with 122 additions and 8 deletions

View File

@@ -2,6 +2,8 @@ from datetime import timedelta
from flask import current_app
from app.dao.fact_processing_time_dao import insert_update_processing_time
from app.models import FactProcessingTime
from app.utils import get_london_midnight_in_utc
from app.dao.notifications_dao import dao_get_total_notifications_sent_per_day_for_performance_platform
from app import performance_platform_client
@@ -11,10 +13,10 @@ def send_processing_time_to_performance_platform(bst_date):
start_time = get_london_midnight_in_utc(bst_date)
end_time = get_london_midnight_in_utc(bst_date + timedelta(days=1))
send_processing_time_for_start_and_end(start_time, end_time)
send_processing_time_for_start_and_end(start_time, end_time, bst_date)
def send_processing_time_for_start_and_end(start_time, end_time):
def send_processing_time_for_start_and_end(start_time, end_time, bst_date):
result = dao_get_total_notifications_sent_per_day_for_performance_platform(start_time, end_time)
current_app.logger.info(
@@ -25,6 +27,11 @@ def send_processing_time_for_start_and_end(start_time, end_time):
send_processing_time_data(start_time, 'messages-total', result.messages_total)
send_processing_time_data(start_time, 'messages-within-10-secs', result.messages_within_10_secs)
insert_update_processing_time(FactProcessingTime(
bst_date=bst_date,
messages_total=result.messages_total,
messages_within_10_secs=result.messages_within_10_secs)
)
def send_processing_time_data(start_time, status, count):