Limit search by recipient to 50 results

Things could get ugly if you use a short search string on a service with
lots of notifications…
This commit is contained in:
Chris Hill-Scott
2020-04-28 11:26:06 +01:00
parent 9f6bfb1b4e
commit 625aad97c9
2 changed files with 23 additions and 1 deletions

View File

@@ -633,7 +633,11 @@ def dao_get_notifications_by_recipient_or_reference(service_id, search_term, not
if notification_type:
filters.append(Notification.notification_type == notification_type)
results = db.session.query(Notification).filter(*filters).order_by(desc(Notification.created_at)).all()
results = db.session.query(Notification)\
.filter(*filters)\
.order_by(desc(Notification.created_at))\
.limit(current_app.config['PAGE_SIZE'])\
.all()
return results