diff options
Diffstat (limited to 'app/services/groups/destroy_service.rb')
-rw-r--r-- | app/services/groups/destroy_service.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb index a896ca5cabc..aeab2667737 100644 --- a/app/services/groups/destroy_service.rb +++ b/app/services/groups/destroy_service.rb @@ -33,7 +33,7 @@ module Groups user_ids_for_project_authorizations_refresh = obtain_user_ids_for_project_authorizations_refresh - destroy_group_bots + destroy_associated_users group.destroy @@ -80,12 +80,9 @@ module Groups end # rubocop:disable CodeReuse/ActiveRecord - def destroy_group_bots - bot_ids = group.members_and_requesters.joins(:user) - .merge(User.project_bot) - .allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/422405') - .pluck(:user_id) + def destroy_associated_users current_user_id = current_user.id + bot_ids = users_to_destroy group.run_after_commit do bot_ids.each do |user_id| @@ -95,6 +92,15 @@ module Groups end # rubocop:enable CodeReuse/ActiveRecord + # rubocop:disable CodeReuse/ActiveRecord + def users_to_destroy + group.members_and_requesters.joins(:user) + .merge(User.project_bot) + .allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/422405') + .pluck(:user_id) + end + # rubocop:enable CodeReuse/ActiveRecord + def publish_event event = Groups::GroupDeletedEvent.new( data: { |