Use MembersFinder ancestors linear scopes

In this commit we're replacing the recursive ancestors scope in
the `MembersFinder` class, for their linear version.

Changelog: performance
parent 8d3b531a
......@@ -70,11 +70,16 @@ class MembersFinder
end
def project_invited_groups
invited_groups_ids_including_ancestors = Gitlab::ObjectHierarchy
invited_groups_and_ancestors = if ::Feature.enabled?(:linear_members_finder_ancestor_scopes, current_user, default_enabled: :yaml)
project.invited_groups
.self_and_ancestors
else
Gitlab::ObjectHierarchy
.new(project.invited_groups)
.base_and_ancestors
.public_or_visible_to_user(current_user)
.select(:id)
end
invited_groups_ids_including_ancestors = invited_groups_and_ancestors.public_or_visible_to_user(current_user).select(:id)
GroupMember.with_source_id(invited_groups_ids_including_ancestors).non_minimal_access
end
......
---
name: linear_members_finder_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70583
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341347
milestone: '14.4'
type: development
group: group::access
default_enabled: false
......@@ -161,6 +161,7 @@ RSpec.describe MembersFinder, '#execute' do
end
context 'when :invited_groups is passed' do
shared_examples 'with invited_groups param' do
subject { described_class.new(project, user2).execute(include_relations: [:inherited, :direct, :invited_groups]) }
let_it_be(:linked_group) { create(:group, :public) }
......@@ -199,4 +200,15 @@ RSpec.describe MembersFinder, '#execute' do
end
end
end
it_behaves_like 'with invited_groups param'
context 'when feature flag :linear_members_finder_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_members_finder_ancestor_scopes: false)
end
it_behaves_like 'with invited_groups param'
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