Commit 8ed313d2 authored by Andy Soiron's avatar Andy Soiron

Merge branch '339440-fj-use-linear-group-descendants-finder-scopes' into 'master'

Enable linear versions in GroupDescendantsFinder

See merge request gitlab-org/gitlab!75877
parents b8e38e38 3c7dc938
...@@ -87,13 +87,7 @@ class GroupDescendantsFinder ...@@ -87,13 +87,7 @@ class GroupDescendantsFinder
visible_to_user = visible_to_user.or(authorized_to_user) visible_to_user = visible_to_user.or(authorized_to_user)
end end
group_to_query = if Feature.enabled?(:linear_group_descendants_finder, current_user, default_enabled: :yaml) parent_group.descendants.where(visible_to_user)
parent_group
else
hierarchy_for_parent
end
group_to_query.descendants.where(visible_to_user)
# rubocop: enable CodeReuse/Finder # rubocop: enable CodeReuse/Finder
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
...@@ -159,13 +153,7 @@ class GroupDescendantsFinder ...@@ -159,13 +153,7 @@ class GroupDescendantsFinder
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def projects_matching_filter def projects_matching_filter
# rubocop: disable CodeReuse/Finder # rubocop: disable CodeReuse/Finder
objects_in_hierarchy = if Feature.enabled?(:linear_group_descendants_finder, current_user, default_enabled: :yaml) projects_nested_in_group = Project.where(namespace_id: parent_group.self_and_descendants.as_ids)
parent_group.self_and_descendants.as_ids
else
hierarchy_for_parent.base_and_descendants.select(:id)
end
projects_nested_in_group = Project.where(namespace_id: objects_in_hierarchy)
params_with_search = params.merge(search: params[:filter]) params_with_search = params.merge(search: params[:filter])
ProjectsFinder.new(params: params_with_search, ProjectsFinder.new(params: params_with_search,
......
---
name: linear_group_descendants_finder
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68954
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339440
milestone: '14.6'
type: development
group: group::access
default_enabled: false
...@@ -17,7 +17,6 @@ RSpec.describe GroupDescendantsFinder do ...@@ -17,7 +17,6 @@ RSpec.describe GroupDescendantsFinder do
described_class.new(current_user: user, parent_group: group, params: params) described_class.new(current_user: user, parent_group: group, params: params)
end end
shared_examples 'group descentants finder examples' do
describe '#has_children?' do describe '#has_children?' do
it 'is true when there are projects' do it 'is true when there are projects' do
create(:project, namespace: group) create(:project, namespace: group)
...@@ -264,15 +263,4 @@ RSpec.describe GroupDescendantsFinder do ...@@ -264,15 +263,4 @@ RSpec.describe GroupDescendantsFinder do
end end
end end
end end
end
it_behaves_like 'group descentants finder examples'
context 'when feature flag :linear_group_descendants_finder is disabled' do
before do
stub_feature_flags(linear_group_descendants_finder: false)
end
it_behaves_like 'group descentants finder 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