mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-30 11:18:54 -04:00
The /platform-admin takes a long time, probably because the marshmallow schema used joins to the service table to return all the service data and is inefficient.
The query itself has not been improved much at all but by not using a marshmallow schema I hope to get the performance gain I am looking for.
This commit is contained in:
@@ -2771,3 +2771,30 @@ def test_get_service_sms_senders_for_service_returns_empty_list_when_service_doe
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == []
|
||||
|
||||
|
||||
def test_get_platform_stats(client, notify_db_session):
|
||||
service_1 = create_service(service_name='Service 1')
|
||||
service_2 = create_service(service_name='Service 2')
|
||||
sms_template = create_template(service=service_1)
|
||||
email_template = create_template(service=service_2, template_type=EMAIL_TYPE)
|
||||
letter_template = create_template(service=service_2, template_type=LETTER_TYPE)
|
||||
create_notification(template=sms_template, status='sending')
|
||||
create_notification(template=sms_template, status='delivered')
|
||||
create_notification(template=sms_template, status='delivered')
|
||||
create_notification(template=sms_template, status='delivered')
|
||||
create_notification(template=email_template, status='temporary-failure')
|
||||
create_notification(template=email_template, status='delivered')
|
||||
create_notification(template=letter_template, status='sending')
|
||||
create_notification(template=letter_template, status='sending')
|
||||
|
||||
response = client.get('/service/platform-stats',
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp == [['email', 'delivered', 1],
|
||||
['email', 'temporary-failure', 1],
|
||||
['sms', 'delivered', 3],
|
||||
['sms', 'sending', 1],
|
||||
['letter', 'sending', 2]]
|
||||
|
||||
Reference in New Issue
Block a user