Commit eea1b885 authored by Nick Thomas's avatar Nick Thomas

Properly fix an introduced N+1 SQL issue loading commit authors

parent 43859f59
...@@ -70,6 +70,9 @@ class Projects::RefsController < Projects::ApplicationController ...@@ -70,6 +70,9 @@ class Projects::RefsController < Projects::ApplicationController
end end
def prerender_commit_full_titles!(commits) 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 = Banzai::ObjectRenderer.new(user: current_user, default_project: @project)
renderer.render(commits, :full_title) renderer.render(commits, :full_title)
end end
......
...@@ -39,12 +39,7 @@ class Commit ...@@ -39,12 +39,7 @@ class Commit
def banzai_render_context(field) def banzai_render_context(field)
pipeline = field == :description ? :commit_description : :single_line pipeline = field == :description ? :commit_description : :single_line
context = { pipeline: pipeline, project: self.project } context = { pipeline: pipeline, project: self.project }
context[:author] = self.author if self.author
# The author is only needed when rendering the description
if field == :description
author = self.author
context[:author] = author if author
end
context context
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment