diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-17 18:32:28 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-05-17 18:32:28 +0300 |
commit | daf9ec6cd1f88e7462cae9dc68eda2dcf793cecf (patch) | |
tree | 798874b97fbb580883924944408d7b1df34619a9 /app/services | |
parent | 2242a2d7d8927e9431291b20d82eb390be7cdc5e (diff) | |
parent | 63da987f0ccbe12761a32198cb817be551def133 (diff) |
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
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. |