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.
This commit is contained in:
Yorick Peterse 2018-02-15 19:32:57 +01:00
parent f330f65960
commit dd52915dc6
No known key found for this signature in database
GPG key ID: EDD30D2BEB691AC9

View file

@ -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