Paginate search results for notifications

The standard way that we indicate that there are more results than can
be returned is by paginating. So even though we don’t intend to paginate
the search results in the admin app, it can still use the presence or
absence of a ‘next’ link to determine whether or not to show a message
about only showing the first 50 results.
This commit is contained in:
Chris Hill-Scott
2020-05-01 11:18:33 +01:00
parent 625aad97c9
commit 80fc5e6600
4 changed files with 98 additions and 63 deletions

View File

@@ -586,7 +586,14 @@ def dao_update_notifications_by_reference(references, update_dict):
@statsd(namespace="dao")
def dao_get_notifications_by_recipient_or_reference(service_id, search_term, notification_type=None, statuses=None):
def dao_get_notifications_by_recipient_or_reference(
service_id,
search_term,
notification_type=None,
statuses=None,
page=1,
page_size=None,
):
if notification_type == SMS_TYPE:
normalised = try_validate_and_format_phone_number(search_term)
@@ -636,8 +643,7 @@ def dao_get_notifications_by_recipient_or_reference(service_id, search_term, not
results = db.session.query(Notification)\
.filter(*filters)\
.order_by(desc(Notification.created_at))\
.limit(current_app.config['PAGE_SIZE'])\
.all()
.paginate(page=page, per_page=page_size)
return results