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
0a544f14
Commit
0a544f14
authored
Dec 15, 2021
by
Alex Pooley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace#self_and_hierarchy linear query
Integrates linear queries for both descendants and ancestors.
parent
42cd0687
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
0 deletions
+55
-0
app/models/namespaces/traversal/linear.rb
app/models/namespaces/traversal/linear.rb
+13
-0
config/feature_flags/development/use_traversal_ids_for_self_and_hierarchy.yml
.../development/use_traversal_ids_for_self_and_hierarchy.yml
+8
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+8
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+26
-0
No files found.
app/models/namespaces/traversal/linear.rb
View file @
0a544f14
...
...
@@ -57,6 +57,13 @@ module Namespaces
traversal_ids
.
present?
end
def
use_traversal_ids_for_self_and_hierarchy?
return
false
unless
use_traversal_ids?
return
false
unless
Feature
.
enabled?
(
:use_traversal_ids_for_self_and_hierarchy
,
root_ancestor
,
default_enabled: :yaml
)
traversal_ids
.
present?
end
def
use_traversal_ids_for_ancestors?
return
false
unless
use_traversal_ids?
return
false
unless
Feature
.
enabled?
(
:use_traversal_ids_for_ancestors
,
root_ancestor
,
default_enabled: :yaml
)
...
...
@@ -107,6 +114,12 @@ module Namespaces
self_and_descendants
.
where
.
not
(
id:
id
)
end
def
self_and_hierarchy
return
super
unless
use_traversal_ids_for_self_and_hierarchy?
self_and_descendants
.
or
(
ancestors
)
end
def
ancestors
(
hierarchy_order:
nil
)
return
super
unless
use_traversal_ids_for_ancestors?
...
...
config/feature_flags/development/use_traversal_ids_for_self_and_hierarchy.yml
0 → 100644
View file @
0a544f14
---
name
:
use_traversal_ids_for_self_and_hierarchy
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76814
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/348527
milestone
:
'
14.7'
type
:
development
group
:
group::workspace
default_enabled
:
false
spec/models/group_spec.rb
View file @
0a544f14
...
...
@@ -502,6 +502,10 @@ RSpec.describe Group do
it
{
expect
(
group
.
descendants
.
to_sql
).
not_to
include
'traversal_ids @>'
}
end
describe
'#self_and_hierarchy'
do
it
{
expect
(
group
.
self_and_hierarchy
.
to_sql
).
not_to
include
'traversal_ids @>'
}
end
describe
'#ancestors'
do
it
{
expect
(
group
.
ancestors
.
to_sql
).
not_to
include
'traversal_ids <@'
}
end
...
...
@@ -526,6 +530,10 @@ RSpec.describe Group do
it
{
expect
(
group
.
descendants
.
to_sql
).
to
include
'traversal_ids @>'
}
end
describe
'#self_and_hierarchy'
do
it
{
expect
(
group
.
self_and_hierarchy
.
to_sql
).
to
include
'traversal_ids @>'
}
end
describe
'#ancestors'
do
it
{
expect
(
group
.
ancestors
.
to_sql
).
to
include
"
\"
namespaces
\"
.
\"
id
\"
=
#{
group
.
parent_id
}
"
}
...
...
spec/models/namespace_spec.rb
View file @
0a544f14
...
...
@@ -1263,6 +1263,32 @@ RSpec.describe Namespace do
end
end
describe
'#use_traversal_ids_for_self_and_hierarchy?'
do
let_it_be
(
:namespace
,
reload:
true
)
{
create
(
:namespace
)
}
subject
{
namespace
.
use_traversal_ids_for_self_and_hierarchy?
}
it
{
is_expected
.
to
eq
true
}
it_behaves_like
'disabled feature flag when traversal_ids is blank'
context
'when use_traversal_ids_for_self_and_hierarchy feature flag is false'
do
before
do
stub_feature_flags
(
use_traversal_ids_for_self_and_hierarchy:
false
)
end
it
{
is_expected
.
to
eq
false
}
end
context
'when use_traversal_ids? feature flag is false'
do
before
do
stub_feature_flags
(
use_traversal_ids:
false
)
end
it
{
is_expected
.
to
eq
false
}
end
end
describe
'#users_with_descendants'
do
let
(
:user_a
)
{
create
(
:user
)
}
let
(
:user_b
)
{
create
(
:user
)
}
...
...
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