Commit 8d1d6aa3 authored by Doug Stull's avatar Doug Stull

Merge branch '339233-fj-use-application_setting-ancestor-linear-scopes' into 'master'

Use ApplicationSetting ancestors linear scopes

See merge request gitlab-org/gitlab!70579
parents 958b6550 d7aaa809
---
name: linear_application_setting_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70579
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341346
milestone: '14.4'
type: development
group: group::access
default_enabled: false
...@@ -384,11 +384,14 @@ module EE ...@@ -384,11 +384,14 @@ module EE
private private
def elasticsearch_limited_project_exists?(project) def elasticsearch_limited_project_exists?(project)
indexed_namespaces = ::Gitlab::ObjectHierarchy project_namespaces = ::Namespace.where(id: project.namespace_id)
.new(::Namespace.where(id: project.namespace_id)) indexed_namespaces = if ::Feature.enabled?(:linear_application_setting_ancestor_scopes, default_enabled: :yaml)
.base_and_ancestors project_namespaces.self_and_ancestors
.joins(:elasticsearch_indexed_namespace) else
::Gitlab::ObjectHierarchy.new(project_namespaces).base_and_ancestors
end
indexed_namespaces = indexed_namespaces.joins(:elasticsearch_indexed_namespace)
indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces) indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces)
indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id)) indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id))
......
...@@ -427,6 +427,7 @@ RSpec.describe ApplicationSetting do ...@@ -427,6 +427,7 @@ RSpec.describe ApplicationSetting do
end end
describe '#elasticsearch_indexes_project?' do describe '#elasticsearch_indexes_project?' do
shared_examples 'whether the project is indexed' 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) }
let(:subgroup) { create(:group, parent: root_group) } let(:subgroup) { create(:group, parent: root_group) }
...@@ -454,6 +455,17 @@ RSpec.describe ApplicationSetting do ...@@ -454,6 +455,17 @@ RSpec.describe ApplicationSetting do
end end
end end
end end
it_behaves_like 'whether the project is indexed'
context 'when feature flag :linear_application_setting_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_application_setting_ancestor_scopes: false)
end
it_behaves_like 'whether the project is indexed'
end
end
end end
context 'projects' do context 'projects' do
......
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