diff options
author | Valery Sizov <valery@gitlab.com> | 2017-05-17 12:37:37 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-05-17 16:49:37 +0300 |
commit | 63da987f0ccbe12761a32198cb817be551def133 (patch) | |
tree | 2eb44eb29f9bba16d28456dfee885e304ead0c58 /app/services | |
parent | 6a2bcb4b2ae8bed4730f3589c2693b17c57b4a75 (diff) |
Get rid of pluck in app/services/members/authorized_destroy_service.rb
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/members/authorized_destroy_service.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb index 9e84e2a8f62..0f94504625a 100644 --- a/app/services/members/authorized_destroy_service.rb +++ b/app/services/members/authorized_destroy_service.rb @@ -26,10 +26,14 @@ module Members def unassign_issues_and_merge_requests(member) if member.is_a?(GroupMember) - issue_ids = IssuesFinder.new(user, group_id: member.source_id, assignee_id: member.user_id). - execute.pluck(:id) + issues = Issue.unscoped.select(1). + 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). execute. |