summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-07-07 15:03:10 -0700
committerStan Hu <stanhu@gmail.com>2017-07-07 16:31:21 -0700
commitb963d45ca4bd883556be5d410feac995f9b50b81 (patch)
tree026d6033803614fb16eafefe029f41fff2f94245 /lib
parent426271dacbb3b7462e4f7a78fa3628bbd267609a (diff)
downloadgitlab-ce-b963d45ca4bd883556be5d410feac995f9b50b81.tar.gz
Remove many N+1 queries with merge requests APIsh-optimize-mr-api
Identified via `ENABLE_BULLET=1 bundle exec rspec spec/requests/api/merge_requests_spec.rb:34` Improves speed of #34159
Diffstat (limited to 'lib')
-rw-r--r--lib/api/merge_requests.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 1118fc7465b..d419d345ec5 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -41,7 +41,9 @@ module API
args[:milestone_title] = args.delete(:milestone)
args[:label_name] = args.delete(:labels)
- merge_requests = MergeRequestsFinder.new(current_user, args).execute.inc_notes_with_associations
+ merge_requests = MergeRequestsFinder.new(current_user, args).execute
+ .inc_notes_with_associations
+ .preload(:target_project, :author, :assignee, :milestone, :merge_request_diff)
merge_requests.reorder(args[:order_by] => args[:sort])
end