Commit 996b1ff1 authored by Yorick Peterse's avatar Yorick Peterse

Add API pagination for deployed merge requests

This endpoint did not apply pagination to the output, which can result
in API calls taking a long time when many deployments are retrieved.

See https://gitlab.com/gitlab-org/gitlab/issues/207523 for more
information.
parent d94f8a61
---
title: Add API pagination for deployed merge requests
merge_request: 25733
author:
type: performance
......@@ -143,6 +143,7 @@ module API
success Entities::MergeRequestBasic
end
params do
use :pagination
requires :deployment_id, type: Integer, desc: 'The deployment ID'
use :merge_requests_base_params
end
......@@ -153,7 +154,7 @@ module API
mr_params = declared_params.merge(deployment_id: params[:deployment_id])
merge_requests = MergeRequestsFinder.new(current_user, mr_params).execute
present merge_requests, { with: Entities::MergeRequestBasic, current_user: current_user }
present paginate(merge_requests), { with: Entities::MergeRequestBasic, current_user: current_user }
end
end
end
......
......@@ -444,6 +444,7 @@ describe API::Deployments do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.map { |d| d['id'] }).to contain_exactly(merge_request1.id, merge_request2.id)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment