Don't return pagination links for API Message log requests

Flask-SQLAlchemy paginate function issues a separate query to get
the total count of rows for a given filter. This query (with
filters used by the API integration Message log page) is slow for
services with large number of notifications.

Since Message log page doesn't actually allow users to paginate
through the response (it only shows the last 50 messages) we can
use limit instead of paginate, which requires passing in another
flag from admin to the dao method.

`count` flag has been added to `paginate` in March 2018, however
there was no release of flask-sqlalchemy since then, so we need
to pull the dev version of the package from Github.
This commit is contained in:
Alexey Bezhan
2019-01-07 17:12:00 +00:00
parent fe498f9a79
commit 47c403f6ab
7 changed files with 42 additions and 3 deletions

View File

@@ -255,6 +255,7 @@ def get_notifications_for_service(
filter_dict=None,
page=1,
page_size=None,
count_pages=True,
limit_days=None,
key_type=None,
personalisation=False,
@@ -300,7 +301,8 @@ def get_notifications_for_service(
return query.order_by(desc(Notification.created_at)).paginate(
page=page,
per_page=page_size
per_page=page_size,
count=count_pages
)