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
5434af3e
Commit
5434af3e
authored
Aug 24, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linear version of groups_including_descendants_by
Changelog: performance
parent
72f0f338
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
app/models/group.rb
app/models/group.rb
+8
-2
config/feature_flags/development/linear_group_including_descendants_by.yml
...ags/development/linear_group_including_descendants_by.yml
+8
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+17
-9
No files found.
app/models/group.rb
View file @
5434af3e
...
@@ -823,10 +823,16 @@ class Group < Namespace
...
@@ -823,10 +823,16 @@ class Group < Namespace
end
end
def
self
.
groups_including_descendants_by
(
group_ids
)
def
self
.
groups_including_descendants_by
(
group_ids
)
groups
=
Group
.
where
(
id:
group_ids
)
if
Feature
.
enabled?
(
:linear_group_including_descendants_by
,
default_enabled: :yaml
)
groups
.
self_and_descendants
else
Gitlab
::
ObjectHierarchy
Gitlab
::
ObjectHierarchy
.
new
(
Group
.
where
(
id:
group_ids
)
)
.
new
(
groups
)
.
base_and_descendants
.
base_and_descendants
end
end
end
def
disable_shared_runners!
def
disable_shared_runners!
update!
(
update!
(
...
...
config/feature_flags/development/linear_group_including_descendants_by.yml
0 → 100644
View file @
5434af3e
---
name
:
linear_group_including_descendants_by
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68835
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/339431
milestone
:
'
14.3'
type
:
development
group
:
group::access
default_enabled
:
false
spec/models/group_spec.rb
View file @
5434af3e
...
@@ -2274,19 +2274,27 @@ RSpec.describe Group do
...
@@ -2274,19 +2274,27 @@ RSpec.describe Group do
end
end
describe
'.groups_including_descendants_by'
do
describe
'.groups_including_descendants_by'
do
it
'returns the expected groups for a group and its descendants'
do
let_it_be
(
:parent_group1
)
{
create
(
:group
)
}
parent_group1
=
create
(
:group
)
let_it_be
(
:parent_group2
)
{
create
(
:group
)
}
child_group1
=
create
(
:group
,
parent:
parent_group1
)
let_it_be
(
:extra_group
)
{
create
(
:group
)
}
child_group2
=
create
(
:group
,
parent:
parent_group1
)
let_it_be
(
:child_group1
)
{
create
(
:group
,
parent:
parent_group1
)
}
let_it_be
(
:child_group2
)
{
create
(
:group
,
parent:
parent_group1
)
}
let_it_be
(
:child_group3
)
{
create
(
:group
,
parent:
parent_group2
)
}
parent_group2
=
create
(
:group
)
subject
{
described_class
.
groups_including_descendants_by
([
parent_group2
.
id
,
parent_group1
.
id
])
}
child_group3
=
create
(
:group
,
parent:
parent_group2
)
create
(
:group
)
shared_examples
'returns the expected groups for a group and its descendants'
do
specify
{
is_expected
.
to
contain_exactly
(
parent_group1
,
parent_group2
,
child_group1
,
child_group2
,
child_group3
)
}
end
it_behaves_like
'returns the expected groups for a group and its descendants'
groups
=
described_class
.
groups_including_descendants_by
([
parent_group2
.
id
,
parent_group1
.
id
])
context
'when :linear_group_including_descendants_by feature flag is disabled'
do
before
do
stub_feature_flags
(
linear_group_including_descendants_by:
false
)
end
expect
(
groups
).
to
contain_exactly
(
parent_group1
,
parent_group2
,
child_group1
,
child_group2
,
child_group3
)
it_behaves_like
'returns the expected groups for a group and its descendants'
end
end
end
end
...
...
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