mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
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:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user