Commit e20d6421 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'sh-improve-mr-api' into 'master'

Paginate the merge requests API earlier to avoid eager loading every merge request

See merge request !12764
parents 3c2fd9d5 1f0ee9ca
......@@ -44,9 +44,9 @@ module API
args[:label_name] = args.delete(:labels)
merge_requests = MergeRequestsFinder.new(current_user, args).execute
.preload(:notes, :target_project, :author, :assignee, :milestone, :merge_request_diff, :labels)
merge_requests.reorder(args[:order_by] => args[:sort])
merge_requests = merge_requests.reorder(args[:order_by] => args[:sort])
paginate(merge_requests)
.preload(:notes, :target_project, :author, :assignee, :milestone, :merge_request_diff, :labels)
end
params :optional_params_ce do
......@@ -85,7 +85,7 @@ module API
merge_requests = find_merge_requests(project_id: user_project.id)
issuable_metadata = issuable_meta_data(merge_requests, 'MergeRequest')
present paginate(merge_requests), with: Entities::MergeRequestBasic, current_user: current_user, project: user_project, issuable_metadata: issuable_metadata
present merge_requests, with: Entities::MergeRequestBasic, current_user: current_user, project: user_project, issuable_metadata: issuable_metadata
end
desc 'Create a merge request' do
......
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