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:
Rebecca Law
2017-10-23 10:58:06 +01:00
parent f6cdfdb640
commit bfb8528ea9
3 changed files with 75 additions and 2 deletions

View File

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