diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-15 19:32:57 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-22 18:55:36 +0100 |
commit | dd52915dc605071eba17fb3876229d2db54481f6 (patch) | |
tree | 0b796da98321a54f3e06b4165d903c8dcf2cccfd /app/finders | |
parent | f330f6596094751ec03dbde4eb8389d0281acaae (diff) | |
download | gitlab-ce-dd52915dc605071eba17fb3876229d2db54481f6.tar.gz |
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.
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/autocomplete_users_finder.rb | 10 |
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 |