Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b5ec6097
Commit
b5ec6097
authored
Mar 06, 2018
by
Andrew Newdigate
Committed by
Sean McGivern
Mar 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Gitaly n+1 in NetworkController#show
parent
af84ccbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
20 deletions
+17
-20
app/controllers/projects/network_controller.rb
app/controllers/projects/network_controller.rb
+11
-14
app/models/network/commit.rb
app/models/network/commit.rb
+1
-6
changelogs/unreleased/an-network-controller-fix.yml
changelogs/unreleased/an-network-controller-fix.yml
+5
-0
No files found.
app/controllers/projects/network_controller.rb
View file @
b5ec6097
...
...
@@ -9,25 +9,22 @@ class Projects::NetworkController < Projects::ApplicationController
before_action
:assign_commit
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
))
@commit_url
=
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
respond_to
do
|
format
|
format
.
html
do
if
@options
[
:extended_sha1
]
&&
!
@commit
flash
.
now
[
:alert
]
=
"Git revision '
#{
@options
[
:extended_sha1
]
}
' does not exist."
end
end
@url
=
project_network_path
(
@project
,
@ref
,
@options
.
merge
(
format: :json
))
@commit_url
=
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
format
.
json
do
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
,
@options
[
:filter_ref
])
respond_to
do
|
format
|
format
.
html
do
if
@options
[
:extended_sha1
]
&&
!
@commit
flash
.
now
[
:alert
]
=
"Git revision '
#{
@options
[
:extended_sha1
]
}
' does not exist."
end
end
render
format
.
json
do
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
,
@options
[
:filter_ref
])
end
end
render
end
def
assign_commit
...
...
app/models/network/commit.rb
View file @
b5ec6097
...
...
@@ -24,12 +24,7 @@ module Network
end
def
parents
(
map
)
@commit
.
parents
.
map
do
|
p
|
if
map
.
include?
(
p
.
id
)
map
[
p
.
id
]
end
end
.
compact
map
.
values_at
(
*
@commit
.
parent_ids
).
compact
end
end
end
changelogs/unreleased/an-network-controller-fix.yml
0 → 100644
View file @
b5ec6097
---
title
:
Prevent the graphs page from generating unnecessary Gitaly requests
merge_request
:
37602
author
:
type
:
performance
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment