Skip to content

Commit

Permalink
fix pagination and query as param
Browse files Browse the repository at this point in the history
Change-Id: I0e5c10ba3de6d623a2fee3771d1d65fe9ff1e6c7
  • Loading branch information
ylamgarchal committed Sep 23, 2024
1 parent 197bbb7 commit 1c4a252
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dci/api/v1/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def _handle_pagination(args):
limit_max = 200
default_limit = 20
default_offset = 0
offset = args.get("offset", default_offset)
limit = min(args.get("limit", default_limit), limit_max)
offset = int(args.get("offset", default_offset))
limit = min(int(args.get("limit", default_limit)), limit_max)
return (offset, limit)


Expand Down Expand Up @@ -251,13 +251,12 @@ def tasks_pipelines_status(user):
@api.route("/analytics/jobs", methods=["GET", "POST"])
@decorators.login_required
def tasks_jobs(user):
if user.is_not_super_admin() and user.is_not_epm():
if user.is_not_super_admin() and user.is_not_epm() and user.is_not_read_only_user():
raise dci_exc.Unauthorized()

args = flask.request.args.to_dict()
offset, limit = _handle_pagination(args)
payload = flask.request.json
query_string = payload["query"]
query_string = args.get("query")
es_query = qed.build(query_string)
es_query["sort"] = [
{"created_at": {"order": "desc", "format": "strict_date_optional_time"}}
Expand Down

0 comments on commit 1c4a252

Please sign in to comment.