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
e0cc0fc6
Commit
e0cc0fc6
authored
Jul 02, 2021
by
Alex Pooley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Namespace#all_projects performance
Changelog: performance
parent
9dce5fff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
app/models/namespace.rb
app/models/namespace.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+8
-0
No files found.
app/models/namespace.rb
View file @
e0cc0fc6
...
...
@@ -280,7 +280,7 @@ class Namespace < ApplicationRecord
# that belongs to this namespace
def
all_projects
if
Feature
.
enabled?
(
:recursive_approach_for_all_projects
,
default_enabled: :yaml
)
namespace
=
user?
?
self
:
self_and_descendants
namespace
=
user?
?
self
:
self_and_descendant
_id
s
Project
.
where
(
namespace:
namespace
)
else
Project
.
inside_path
(
full_path
)
...
...
spec/models/namespace_spec.rb
View file @
e0cc0fc6
...
...
@@ -1097,6 +1097,14 @@ RSpec.describe Namespace do
end
include_examples
'#all_projects'
# Using #self_and_descendant instead of #self_and_descendant_ids can produce
# very slow queries.
it
'calls self_and_descendant_ids'
do
namespace
=
create
(
:group
)
expect
(
namespace
).
to
receive
(
:self_and_descendant_ids
)
namespace
.
all_projects
end
end
context
'with use_traversal_ids feature flag disabled'
do
...
...
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