Commit daf9ec6c authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'get_rid_of_pluck' into 'master'

Get rid of pluck in app/services/members/authorized_destroy_service.rb

Closes #32372

See merge request !11433
parents 2242a2d7 63da987f
...@@ -26,10 +26,14 @@ module Members ...@@ -26,10 +26,14 @@ module Members
def unassign_issues_and_merge_requests(member) def unassign_issues_and_merge_requests(member)
if member.is_a?(GroupMember) if member.is_a?(GroupMember)
issue_ids = IssuesFinder.new(user, group_id: member.source_id, assignee_id: member.user_id). issues = Issue.unscoped.select(1).
execute.pluck(:id) joins(:project).
where('issues.id = issue_assignees.issue_id AND projects.namespace_id = ?', member.source_id)
IssueAssignee.delete_all(issue_id: issue_ids, user_id: member.user_id) # DELETE FROM issue_assignees WHERE user_id = X AND EXISTS (...)
IssueAssignee.unscoped.
where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues).
delete_all
MergeRequestsFinder.new(user, group_id: member.source_id, assignee_id: member.user_id). MergeRequestsFinder.new(user, group_id: member.source_id, assignee_id: member.user_id).
execute. execute.
......
---
title: Issue assignees are now removed without loading unnecessary data into memory
merge_request:
author:
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