summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-05-17 12:37:37 +0300
committerValery Sizov <valery@gitlab.com>2017-05-17 16:49:37 +0300
commit63da987f0ccbe12761a32198cb817be551def133 (patch)
tree2eb44eb29f9bba16d28456dfee885e304ead0c58
parent6a2bcb4b2ae8bed4730f3589c2693b17c57b4a75 (diff)
downloadgitlab-ce-63da987f0ccbe12761a32198cb817be551def133.tar.gz
Get rid of pluck in app/services/members/authorized_destroy_service.rbget_rid_of_pluck
-rw-r--r--app/services/members/authorized_destroy_service.rb10
-rw-r--r--changelogs/unreleased/get_rid_of_pluck.yml4
2 files changed, 11 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.
diff --git a/changelogs/unreleased/get_rid_of_pluck.yml b/changelogs/unreleased/get_rid_of_pluck.yml
new file mode 100644
index 00000000000..987af5e9317
--- /dev/null
+++ b/changelogs/unreleased/get_rid_of_pluck.yml
@@ -0,0 +1,4 @@
+---
+title: Issue assignees are now removed without loading unnecessary data into memory
+merge_request:
+author: