diff --git a/pagure/api/user.py b/pagure/api/user.py index 4f0f8e0..986a96f 100644 --- a/pagure/api/user.py +++ b/pagure/api/user.py @@ -1103,19 +1103,11 @@ def api_view_user_requests_actionable(username): """ status = flask.request.args.get('status', 'open') - page = flask.request.args.get('page', 1) - try: - page = int(page) - if page <= 0: - raise ValueError() - except ValueError: - raise pagure.exceptions.APIError( - 400, error_code=APIERROR.ENOCODE, - error='Invalid page requested') - - offset = (page - 1) * 50 - limit = page * 50 + page = get_page() + per_page = get_per_page() + offset = (page - 1) * per_page + limit = per_page orig_status = status if status.lower() == 'all': @@ -1123,10 +1115,20 @@ def api_view_user_requests_actionable(username): else: status = status.capitalize() + pullrequests_cnt = pagure.lib.get_pull_request_of_user( + flask.g.session, + username=username, + status=status, + count=True, + ) + pagination = pagure.lib.get_pagination_metadata( + flask.request, page, per_page, pullrequests_cnt) + pullrequests = pagure.lib.get_pull_request_of_user( flask.g.session, username=username, status=status, + actionable=username, offset=offset, limit=limit, ) @@ -1134,7 +1136,6 @@ def api_view_user_requests_actionable(username): pullrequestslist = [ pr.to_json(public=True, api=True) for pr in pullrequests - if pr.user.username != username ] return flask.jsonify({ @@ -1144,5 +1145,6 @@ def api_view_user_requests_actionable(username): 'username': username, 'status': orig_status, 'page': page, - } + }, + 'pagination': pagination, })