Commit e84b9df7 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '35733-eliminate-feature-flag' into 'master'

Eliminate group templates finder feature flag

Closes #35733

See merge request gitlab-org/gitlab!20947
parents 5c547dd6 225284c1
...@@ -21,30 +21,20 @@ class GroupsWithTemplatesFinder ...@@ -21,30 +21,20 @@ class GroupsWithTemplatesFinder
attr_reader :group_id attr_reader :group_id
# Cleanup issue: https://gitlab.com/gitlab-org/gitlab/issues/35733
def extended_group_search def extended_group_search
if ::Feature.enabled?(:optimized_groups_with_templates_finder) groups = Group.with_project_templates
groups = Group.with_project_templates_optimized
groups_with_plan = Gitlab::ObjectHierarchy groups_with_plan = Gitlab::ObjectHierarchy
.new(groups) .new(groups)
.base_and_ancestors .base_and_ancestors
.with_feature_available_in_plan(:group_project_templates) .with_feature_available_in_plan(:group_project_templates)
Gitlab::ObjectHierarchy.new(groups_with_plan).base_and_descendants Gitlab::ObjectHierarchy.new(groups_with_plan).base_and_descendants
else
groups = Group.with_feature_available_in_plan(:group_project_templates)
Gitlab::ObjectHierarchy.new(groups).base_and_descendants
end
end end
def simple_group_search(groups) def simple_group_search(groups)
groups = group_id ? groups.find_by(id: group_id)&.self_and_ancestors : groups # rubocop: disable CodeReuse/ActiveRecord groups = group_id ? groups.find_by(id: group_id)&.self_and_ancestors : groups # rubocop: disable CodeReuse/ActiveRecord
return Group.none unless groups return Group.none unless groups
if ::Feature.enabled?(:optimized_groups_with_templates_finder)
groups.with_project_templates_optimized
else
groups.with_project_templates groups.with_project_templates
end end
end
end end
...@@ -62,12 +62,7 @@ module EE ...@@ -62,12 +62,7 @@ module EE
joins(:ldap_group_links).where(ldap_group_links: { provider: provider }) joins(:ldap_group_links).where(ldap_group_links: { provider: provider })
end end
scope :with_project_templates, -> do scope :with_project_templates, -> { where.not(custom_project_templates_group_id: nil) }
joins("INNER JOIN projects ON projects.namespace_id = namespaces.custom_project_templates_group_id")
.distinct
end
scope :with_project_templates_optimized, -> { where.not(custom_project_templates_group_id: nil) }
scope :with_custom_file_templates, -> do scope :with_custom_file_templates, -> do
preload( preload(
......
---
title: Improve the performance of group templates finder
merge_request: 20947
author:
type: changed
...@@ -269,7 +269,7 @@ describe 'New project' do ...@@ -269,7 +269,7 @@ describe 'New project' do
end end
end end
shared_context 'when custom project group template is set' do context 'when custom project group template is set' do
let(:group1) { create(:group) } let(:group1) { create(:group) }
let(:group2) { create(:group) } let(:group2) { create(:group) }
let(:group3) { create(:group) } let(:group3) { create(:group) }
...@@ -429,23 +429,6 @@ describe 'New project' do ...@@ -429,23 +429,6 @@ describe 'New project' do
end end
end end
# Cleanup issue: https://gitlab.com/gitlab-org/gitlab/issues/35733
context 'when `optimized_groups_with_templates_finder` feature flag is enabled' do
before do
stub_feature_flags(optimized_groups_with_templates_finder: true)
end
include_context 'when custom project group template is set'
end
context 'when `optimized_groups_with_templates_finder` feature flag is disabled' do
before do
stub_feature_flags(optimized_groups_with_templates_finder: false)
end
include_context 'when custom project group template is set'
end
context 'when group template is not set' do context 'when group template is not set' do
it_behaves_like 'group templates displayed' do it_behaves_like 'group templates displayed' do
let(:template_number) { 0 } let(:template_number) { 0 }
......
...@@ -26,7 +26,6 @@ describe GroupsWithTemplatesFinder do ...@@ -26,7 +26,6 @@ describe GroupsWithTemplatesFinder do
create(:gitlab_subscription, :silver, namespace: group_2) create(:gitlab_subscription, :silver, namespace: group_2)
end end
shared_examples 'GroupsWithTemplatesFinder examples' do
describe 'without group id' do describe 'without group id' do
it 'returns all groups' do it 'returns all groups' do
expect(described_class.new.execute).to contain_exactly(group_1, group_2, group_3) expect(described_class.new.execute).to contain_exactly(group_1, group_2, group_3)
...@@ -117,21 +116,4 @@ describe GroupsWithTemplatesFinder do ...@@ -117,21 +116,4 @@ describe GroupsWithTemplatesFinder do
end end
end end
end end
end
context 'when `optimized_groups_with_templates_finder` feature flag is enabled' do
before do
stub_feature_flags(optimized_groups_with_templates_finder: true)
end
include_examples 'GroupsWithTemplatesFinder examples'
end
context 'when `optimized_groups_with_templates_finder` feature flag is disabled' do
before do
stub_feature_flags(optimized_groups_with_templates_finder: false)
end
include_examples 'GroupsWithTemplatesFinder examples'
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment