mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-24 18:09:41 -04:00
Remove last and total keys from pagination links
These don't appear to be used anywhere in the admin app and this route is only used by the admin app. Therefore it is safe to remove them. We remove them because the calculate the total number of notifications or the final page number of results can be particularly slow for services with many many notifications, for example 100 seconds for a service with 500k notifications sent in the past 7 days. Given neither are being used, this will give us the potential in the next commit to reduce the number of slow queries and improve page load times. Note, I've kept the scope small by only introducing the new pagination function for this one endpoint but there could be scope in future to get all pagination using the next function if appropriate.
This commit is contained in:
@@ -1881,11 +1881,9 @@ def test_get_notifications_for_service_without_page_count(
|
||||
count_pages=False
|
||||
)
|
||||
assert len(resp['notifications']) == 1
|
||||
assert resp['total'] is None
|
||||
assert resp['notifications'][0]['id'] == str(without_job.id)
|
||||
assert 'prev' not in resp['links']
|
||||
assert 'next' not in resp['links']
|
||||
assert 'last' not in resp['links']
|
||||
|
||||
|
||||
def test_get_notifications_for_service_pagination_links(
|
||||
@@ -1902,10 +1900,8 @@ def test_get_notifications_for_service_pagination_links(
|
||||
service_id=sample_template.service_id
|
||||
)
|
||||
|
||||
assert resp['total'] == 101
|
||||
assert 'prev' not in resp['links']
|
||||
assert '?page=2' in resp['links']['next']
|
||||
assert '?page=3' in resp['links']['last']
|
||||
|
||||
resp = admin_request.get(
|
||||
'service.get_all_notifications_for_service',
|
||||
@@ -1913,10 +1909,8 @@ def test_get_notifications_for_service_pagination_links(
|
||||
page=2
|
||||
)
|
||||
|
||||
assert resp['total'] == 101
|
||||
assert '?page=1' in resp['links']['prev']
|
||||
assert '?page=3' in resp['links']['next']
|
||||
assert '?page=3' in resp['links']['last']
|
||||
|
||||
resp = admin_request.get(
|
||||
'service.get_all_notifications_for_service',
|
||||
@@ -1924,10 +1918,8 @@ def test_get_notifications_for_service_pagination_links(
|
||||
page=3
|
||||
)
|
||||
|
||||
assert resp['total'] == 101
|
||||
assert '?page=2' in resp['links']['prev']
|
||||
assert 'next' not in resp['links']
|
||||
assert 'last' not in resp['links']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('should_prefix', [
|
||||
|
||||
Reference in New Issue
Block a user