Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-02-15 21:32:57 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2018-02-22 20:55:36 +0300
commitdd52915dc605071eba17fb3876229d2db54481f6 (patch)
tree0b796da98321a54f3e06b4165d903c8dcf2cccfd
parentf330f6596094751ec03dbde4eb8389d0281acaae (diff)
Don't pluck IDs in AutocompleteUsersFinder
We can instead just use a UNION. This removes the need for plucking hundreds if not thousands of IDs into memory when a project has many members.
-rw-r--r--app/finders/autocomplete_users_finder.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/finders/autocomplete_users_finder.rb b/app/finders/autocomplete_users_finder.rb
index c3f5358b577..3f10727be8c 100644
--- a/app/finders/autocomplete_users_finder.rb
+++ b/app/finders/autocomplete_users_finder.rb
@@ -52,9 +52,13 @@ class AutocompleteUsersFinder
end
def users_from_project
- user_ids = project.team.users.pluck(:id)
- user_ids << author_id if author_id.present?
+ if author_id.present?
+ union = Gitlab::SQL::Union
+ .new([project.team.users, User.where(id: author_id)])
- User.where(id: user_ids)
+ User.from("(#{union.to_sql}) #{User.table_name}")
+ else
+ project.authorized_users
+ end
end
end