diff options
author | Stan Hu <stanhu@gmail.com> | 2017-07-10 13:56:46 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-07-10 13:56:46 -0700 |
commit | ef526ff33c01d75af5d24e4f13630213815d74d3 (patch) | |
tree | 5eba84cfaa455680064b78f8aa0c3daf5a658e49 /lib | |
parent | 31ada792621f17ab7f4f7475405ddd1ec9e9673a (diff) | |
download | gitlab-ce-ef526ff33c01d75af5d24e4f13630213815d74d3.tar.gz |
Paginate the merge requests API earlier to avoid eager loading every merge request
Fixes a performance regression introduced in !12732
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 4ad1eef4ff1..9fd557e9cda 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -44,6 +44,7 @@ module API args[:label_name] = args.delete(:labels) merge_requests = MergeRequestsFinder.new(current_user, args).execute + merge_requests = paginate(merge_requests) .preload(:notes, :target_project, :author, :assignee, :milestone, :merge_request_diff, :labels) merge_requests.reorder(args[:order_by] => args[:sort]) @@ -85,7 +86,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 |