summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-06-04 10:12:23 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-06-04 10:12:23 +0000
commit0b4f9ff4068af6776b495d9332aeecf58e48786f (patch)
tree5360634832d137d4f665c5f015ccbf18b6d6f704
parentc63cd738b1eed64565cfa8213799c75b5371f994 (diff)
parentbd4bfcc6411e4819c0c67717095bb2e54e7bb6df (diff)
downloadgitlab-ce-0b4f9ff4068af6776b495d9332aeecf58e48786f.tar.gz
Merge branch 'sh-fix-source-project-nplus-one' into 'master'47213-epics-page-styling-is-broken
Fix N+1 with source_projects in merge requests API See merge request gitlab-org/gitlab-ce!19346
-rw-r--r--changelogs/unreleased/sh-fix-source-project-nplus-one.yml5
-rw-r--r--lib/api/merge_requests.rb2
2 files changed, 6 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-source-project-nplus-one.yml b/changelogs/unreleased/sh-fix-source-project-nplus-one.yml
new file mode 100644
index 00000000000..9d78ad6408c
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-source-project-nplus-one.yml
@@ -0,0 +1,5 @@
+---
+title: Fix N+1 with source_projects in merge requests API
+merge_request:
+author:
+type: performance
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index b1e510d72de..278d53427f0 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -38,7 +38,7 @@ module API
merge_requests = MergeRequestsFinder.new(current_user, args).execute
.reorder(args[:order_by] => args[:sort])
merge_requests = paginate(merge_requests)
- .preload(:target_project)
+ .preload(:source_project, :target_project)
return merge_requests if args[:view] == 'simple'