diff options
author | Nick Thomas <nick@gitlab.com> | 2018-09-05 23:05:09 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-09-06 16:04:21 +0100 |
commit | eea1b88547bb038b34b0691f0280d54d5dd23947 (patch) | |
tree | 3a148fdc021d97cd5b0fc565e755b579908201e9 | |
parent | 43859f59aec7d8dd0ce9998ea7ddfe365cd51391 (diff) | |
download | gitlab-ce-eea1b88547bb038b34b0691f0280d54d5dd23947.tar.gz |
Properly fix an introduced N+1 SQL issue loading commit authors
-rw-r--r-- | app/controllers/projects/refs_controller.rb | 3 | ||||
-rw-r--r-- | app/models/commit.rb | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index 200054b4746..0fed7f6576c 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -70,6 +70,9 @@ class Projects::RefsController < Projects::ApplicationController end def prerender_commit_full_titles!(commits) + # Preload commit authors as they are used in rendering + commits.each(&:lazy_author) + renderer = Banzai::ObjectRenderer.new(user: current_user, default_project: @project) renderer.render(commits, :full_title) end diff --git a/app/models/commit.rb b/app/models/commit.rb index c993f3ed507..49c36ad9d3f 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -39,12 +39,7 @@ class Commit def banzai_render_context(field) pipeline = field == :description ? :commit_description : :single_line context = { pipeline: pipeline, project: self.project } - - # The author is only needed when rendering the description - if field == :description - author = self.author - context[:author] = author if author - end + context[:author] = self.author if self.author context end |