Don't request pagination links for API Message log page

Counting pages for API notifications takes a long time for services
with a lot of sent messages (since it issues a `count(*)` query for
the given filter). Since API message log doesn't have a "Next page"
link we can skip the count by setting a flag on the API request.
This commit is contained in:
Alexey Bezhan
2019-01-08 15:35:44 +00:00
parent 0b22fff751
commit 6cd18f87de
3 changed files with 25 additions and 22 deletions

View File

@@ -1863,6 +1863,7 @@ def mock_get_notifications(
job_id=None,
page=1,
page_size=50,
count_pages=None,
template_type=None,
status=None,
limit_days=None,
@@ -1896,6 +1897,7 @@ def mock_get_notifications(
template=template,
rows=rows,
job=job,
with_links=True if count_pages is None else count_pages,
personalisation=personalisation,
template_type=diff_template_type,
client_reference=client_reference,
@@ -1915,6 +1917,7 @@ def mock_get_notifications_with_previous_next(mocker):
def _get_notifications(service_id,
job_id=None,
page=1,
count_pages=None,
template_type=None,
status=None,
limit_days=None,
@@ -1923,7 +1926,7 @@ def mock_get_notifications_with_previous_next(mocker):
to=None,
include_one_off=None
):
return notification_json(service_id, with_links=True)
return notification_json(service_id, rows=50, with_links=True if count_pages is None else count_pages)
return mocker.patch(
'app.notification_api_client.get_notifications_for_service',
@@ -1936,6 +1939,7 @@ def mock_get_notifications_with_no_notifications(mocker):
def _get_notifications(service_id,
job_id=None,
page=1,
count_pages=None,
template_type=None,
status=None,
limit_days=None,