mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
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:
@@ -11,9 +11,9 @@ def test_backfill_processing_time_works_for_correct_dates(mocker, notify_api):
|
||||
backfill_processing_time.callback.__wrapped__(datetime(2017, 8, 1), datetime(2017, 8, 3))
|
||||
|
||||
assert send_mock.call_count == 3
|
||||
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0))
|
||||
send_mock.assert_any_call(datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 23, 0))
|
||||
send_mock.assert_any_call(datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 23, 0))
|
||||
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 0, 0))
|
||||
send_mock.assert_any_call(datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 0, 0))
|
||||
send_mock.assert_any_call(datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 23, 0), datetime(2017, 8, 4, 0, 0))
|
||||
|
||||
|
||||
def test_backfill_totals_works_for_correct_dates(mocker, notify_api):
|
||||
|
||||
36
tests/app/dao/test_fact_processing_time_dao.py
Normal file
36
tests/app/dao/test_fact_processing_time_dao.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from datetime import datetime
|
||||
|
||||
from app.dao import fact_processing_time_dao
|
||||
from app.models import FactProcessingTime
|
||||
|
||||
|
||||
def test_insert_update_processing_time(notify_db_session):
|
||||
data = FactProcessingTime(
|
||||
bst_date=datetime(2021, 2, 22).date(),
|
||||
messages_total=3,
|
||||
messages_within_10_secs=2
|
||||
)
|
||||
|
||||
fact_processing_time_dao.insert_update_processing_time(data)
|
||||
|
||||
result = FactProcessingTime.query.all()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].bst_date == datetime(2021, 2, 22).date()
|
||||
assert result[0].messages_total == 3
|
||||
assert result[0].messages_within_10_secs == 2
|
||||
|
||||
data = FactProcessingTime(
|
||||
bst_date=datetime(2021, 2, 22).date(),
|
||||
messages_total=4,
|
||||
messages_within_10_secs=3
|
||||
)
|
||||
|
||||
fact_processing_time_dao.insert_update_processing_time(data)
|
||||
|
||||
result = FactProcessingTime.query.all()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].bst_date == datetime(2021, 2, 22).date()
|
||||
assert result[0].messages_total == 4
|
||||
assert result[0].messages_within_10_secs == 3
|
||||
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta, date
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.models import FactProcessingTime
|
||||
from tests.app.db import create_notification
|
||||
from app.performance_platform.processing_time import (
|
||||
send_processing_time_to_performance_platform,
|
||||
@@ -23,6 +24,11 @@ def test_send_processing_time_to_performance_platform_generates_correct_calls(mo
|
||||
|
||||
send_mock.assert_any_call(datetime(2016, 10, 16, 23, 0), 'messages-total', 2)
|
||||
send_mock.assert_any_call(datetime(2016, 10, 16, 23, 0), 'messages-within-10-secs', 1)
|
||||
persisted_to_db = FactProcessingTime.query.all()
|
||||
assert len(persisted_to_db) == 1
|
||||
assert persisted_to_db[0].bst_date == date(2016, 10, 17)
|
||||
assert persisted_to_db[0].messages_total == 2
|
||||
assert persisted_to_db[0].messages_within_10_secs == 1
|
||||
|
||||
|
||||
def test_send_processing_time_to_performance_platform_creates_correct_call_to_perf_platform(mocker):
|
||||
|
||||
Reference in New Issue
Block a user