summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-05-17 15:32:28 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-05-17 15:32:28 +0000
commitdaf9ec6cd1f88e7462cae9dc68eda2dcf793cecf (patch)
tree798874b97fbb580883924944408d7b1df34619a9
parent2242a2d7d8927e9431291b20d82eb390be7cdc5e (diff)
parent63da987f0ccbe12761a32198cb817be551def133 (diff)
downloadgitlab-ce-daf9ec6cd1f88e7462cae9dc68eda2dcf793cecf.tar.gz
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
-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: