Eager load head pipeline projects for MRs index

This ensures the project of an MR's head pipeline is eager loaded,
preventing an N+1 query problem from occurring when viewing the list of
MRs of a project.
This commit is contained in:
Yorick Peterse 2017-08-28 17:35:10 +02:00
parent 073811074b
commit b870ae1f59
No known key found for this signature in database
GPG key ID: EDD30D2BEB691AC9
2 changed files with 16 additions and 1 deletions

View file

@ -15,7 +15,17 @@ module IssuableCollections
end
def merge_requests_collection
merge_requests_finder.execute.preload(:source_project, :target_project, :author, :assignee, :labels, :milestone, :head_pipeline, target_project: :namespace, merge_request_diff: :merge_request_diff_commits)
merge_requests_finder.execute.preload(
:source_project,
:target_project,
:author,
:assignee,
:labels,
:milestone,
head_pipeline: :project,
target_project: :namespace,
merge_request_diff: :merge_request_diff_commits
)
end
def issues_finder

View file

@ -0,0 +1,5 @@
---
title: Eager load head pipeline projects for MRs index
merge_request:
author:
type: other