Commit 5e8138aa authored by Sean McGivern's avatar Sean McGivern

Merge branch 'an/network-controller-fix' into 'master'

Fix Gitaly n+1 in NetworkController#show

Closes #37602 and gitaly#1056

See merge request gitlab-org/gitlab-ce!17548
parents af84ccbd b5ec6097
...@@ -9,8 +9,6 @@ class Projects::NetworkController < Projects::ApplicationController ...@@ -9,8 +9,6 @@ class Projects::NetworkController < Projects::ApplicationController
before_action :assign_commit before_action :assign_commit
def show def show
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37602
Gitlab::GitalyClient.allow_n_plus_1_calls do
@url = project_network_path(@project, @ref, @options.merge(format: :json)) @url = project_network_path(@project, @ref, @options.merge(format: :json))
@commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s") @commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
...@@ -28,7 +26,6 @@ class Projects::NetworkController < Projects::ApplicationController ...@@ -28,7 +26,6 @@ class Projects::NetworkController < Projects::ApplicationController
render render
end end
end
def assign_commit def assign_commit
return if params[:extended_sha1].blank? return if params[:extended_sha1].blank?
......
...@@ -24,12 +24,7 @@ module Network ...@@ -24,12 +24,7 @@ module Network
end end
def parents(map) def parents(map)
@commit.parents.map do |p| map.values_at(*@commit.parent_ids).compact
if map.include?(p.id)
map[p.id]
end
end
.compact
end end
end end
end end
---
title: Prevent the graphs page from generating unnecessary Gitaly requests
merge_request: 37602
author:
type: performance
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