User ParticipantService linear ancestor scopes

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

Changelog: performance
parent 532e3e3e
......@@ -36,14 +36,17 @@ module Projects
private
def project_members_through_invited_groups
groups_with_ancestors_ids = Gitlab::ObjectHierarchy
groups_with_ancestors = if ::Feature.enabled?(:linear_participants_service_ancestor_scopes, current_user, default_enabled: :yaml)
visible_groups.self_and_ancestors
else
Gitlab::ObjectHierarchy
.new(visible_groups)
.base_and_ancestors
.pluck_primary_key
end
GroupMember
.active_without_invites_and_requests
.with_source_id(groups_with_ancestors_ids)
.with_source_id(groups_with_ancestors.pluck_primary_key)
end
def visible_groups
......
---
name: linear_participants_service_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70684
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341348
milestone: '14.4'
type: development
group: group::access
default_enabled: false
......@@ -104,6 +104,7 @@ RSpec.describe Projects::ParticipantsService do
describe '#project_members' do
subject(:usernames) { service.project_members.map { |member| member[:username] } }
shared_examples 'return project members' do
context 'when there is a project in group namespace' do
let_it_be(:public_group) { create(:group, :public) }
let_it_be(:public_project) { create(:project, :public, namespace: public_group)}
......@@ -204,4 +205,15 @@ RSpec.describe Projects::ParticipantsService do
end
end
end
it_behaves_like 'return project members'
context 'when feature flag :linear_participants_service_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_participants_service_ancestor_scopes: false)
end
it_behaves_like 'return project members'
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