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:
parent
f330f65960
commit
dd52915dc6
1 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue