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
b4ea0323
Commit
b4ea0323
authored
Aug 25, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linear version GroupsWithTemplatesFinder#extended_group_search
Changelog: performance EE: true
parent
9e0fc449
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
41 deletions
+71
-41
config/feature_flags/development/linear_groups_template_finder_extended_group_search.yml
...t/linear_groups_template_finder_extended_group_search.yml
+8
-0
ee/app/finders/groups_with_templates_finder.rb
ee/app/finders/groups_with_templates_finder.rb
+11
-1
ee/spec/finders/groups_with_templates_finder_spec.rb
ee/spec/finders/groups_with_templates_finder_spec.rb
+52
-40
No files found.
config/feature_flags/development/linear_groups_template_finder_extended_group_search.yml
0 → 100644
View file @
b4ea0323
---
name
:
linear_groups_template_finder_extended_group_search
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68936
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/339439
milestone
:
'
14.3'
type
:
development
group
:
group::access
default_enabled
:
false
ee/app/finders/groups_with_templates_finder.rb
View file @
b4ea0323
...
...
@@ -24,7 +24,12 @@ class GroupsWithTemplatesFinder
.
base_and_ancestors
.
with_feature_available_in_plan
(
:group_project_templates
)
Gitlab
::
ObjectHierarchy
.
new
(
groups_with_plan
).
base_and_descendants
# We're adding an extra query that will be removed once we remove the feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/339439
if
::
Feature
.
enabled?
(
:linear_groups_template_finder_extended_group_search
,
current_group
,
default_enabled: :yaml
)
groups_with_plan
.
self_and_descendants
else
Gitlab
::
ObjectHierarchy
.
new
(
groups_with_plan
).
base_and_descendants
end
end
def
simple_group_search
(
groups
)
...
...
@@ -33,4 +38,9 @@ class GroupsWithTemplatesFinder
groups
.
with_project_templates
end
# This method will be removed https://gitlab.com/gitlab-org/gitlab/-/issues/339439
def
current_group
Group
.
find_by
(
id:
group_id
)
# rubocop:disable CodeReuse/ActiveRecord
end
end
ee/spec/finders/groups_with_templates_finder_spec.rb
View file @
b4ea0323
...
...
@@ -26,56 +26,37 @@ RSpec.describe GroupsWithTemplatesFinder do
create
(
:gitlab_subscription
,
:premium
,
namespace:
group_2
)
end
describe
'without group id'
do
it
'returns all groups'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
group_3
)
end
context
'when namespace checked'
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'returns groups on ultimate/premium plan'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
)
shared_examples
'group template finder examples'
do
describe
'without group id'
do
it
'returns all groups'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
group_3
)
end
context
'w
ith subgroup with template
'
do
context
'w
hen namespace checked
'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'returns groups on ultimate/premium plan'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
subgroup_4
)
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
)
end
end
end
end
describe
'with group id'
do
it
'returns given group with it descendants'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
it
'returns only chosen group'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
it
'returns groups on ultimate/premium plan'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
subgroup_4
)
end
end
end
end
context
'when namespace checked'
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'does not return the group'
do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
describe
'with group id'
do
it
'returns given group with it descendants'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
context
'with subgroup with template'
do
...
...
@@ -87,11 +68,42 @@ RSpec.describe GroupsWithTemplatesFinder do
it
'returns only chosen group'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
end
context
'when namespace checked'
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'returns only chosen subgroup'
do
expect
(
described_class
.
new
(
subgroup_4
.
id
).
execute
).
to
contain_exactly
(
group_1
,
subgroup_4
)
it
'does not return the group'
do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
it
'returns only chosen group'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
it
'returns only chosen subgroup'
do
expect
(
described_class
.
new
(
subgroup_4
.
id
).
execute
).
to
contain_exactly
(
group_1
,
subgroup_4
)
end
end
end
end
end
it_behaves_like
'group template finder examples'
context
'when feature flag :linear_groups_template_finder_extended_group_search is disabled'
do
before
do
stub_feature_flags
(
linear_groups_template_finder_extended_group_search:
false
)
end
it_behaves_like
'group template finder examples'
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