Use linear version ApplicationSettings#elasticsearch_limited_namespaces

Changelog: performance
EE: true
parent fe5831c6
---
name: linear_application_settings_elasticsearch_limited_namespaces
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68931
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339438
milestone: '14.3'
type: development
group: group::access
default_enabled: false
...@@ -231,8 +231,12 @@ module EE ...@@ -231,8 +231,12 @@ module EE
return namespaces if ignore_descendants return namespaces if ignore_descendants
if ::Feature.enabled?(:linear_application_settings_elasticsearch_limited_namespaces, default_enabled: :yaml)
namespaces.self_and_descendants
else
::Gitlab::ObjectHierarchy.new(namespaces).base_and_descendants ::Gitlab::ObjectHierarchy.new(namespaces).base_and_descendants
end end
end
def pseudonymizer_available? def pseudonymizer_available?
License.feature_available?(:pseudonymizer) License.feature_available?(:pseudonymizer)
......
...@@ -400,13 +400,13 @@ RSpec.describe ApplicationSetting do ...@@ -400,13 +400,13 @@ RSpec.describe ApplicationSetting do
context 'with groups' do context 'with groups' do
let(:groups) { create_list(:group, 2) } let(:groups) { create_list(:group, 2) }
let!(:indexed_namespace) { create :elasticsearch_indexed_namespace, namespace: groups.last } let!(:indexed_namespace) { create(:elasticsearch_indexed_namespace, namespace: groups.last) }
let!(:child_group) { create(:group, parent: groups.first) }
let!(:child_group_indexed_through_parent) { create(:group, parent: groups.last) }
it 'returns groups that are allowed to be indexed' do shared_examples 'returns groups that are allowed to be indexed' do
child_group = create(:group, parent: groups.first) specify do
create :elasticsearch_indexed_namespace, namespace: child_group create(:elasticsearch_indexed_namespace, namespace: child_group)
child_group_indexed_through_parent = create(:group, parent: groups.last)
expect(setting.elasticsearch_limited_namespaces).to match_array( expect(setting.elasticsearch_limited_namespaces).to match_array(
[groups.last, child_group, child_group_indexed_through_parent]) [groups.last, child_group, child_group_indexed_through_parent])
...@@ -415,6 +415,17 @@ RSpec.describe ApplicationSetting do ...@@ -415,6 +415,17 @@ RSpec.describe ApplicationSetting do
end end
end end
it_behaves_like 'returns groups that are allowed to be indexed'
context 'when feature flag :linear_application_settings_elasticsearch_limited_namespaces is disabled' do
before do
stub_feature_flags(linear_application_settings_elasticsearch_limited_namespaces: false)
end
it_behaves_like 'returns groups that are allowed to be indexed'
end
end
describe '#elasticsearch_indexes_project?' do describe '#elasticsearch_indexes_project?' do
context 'when project is in a subgroup' do context 'when project is in a subgroup' do
let(:root_group) { create(:group) } let(:root_group) { create(:group) }
......
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