提交 2c40a012 编写于 作者: S Sean McGivern

Don't call `#uniq` on a relation

When there was no project, no search, and no current user or author
param, the AutocompleteController would call `#uniq!` on a relation
instead of an array. This performed the less-efficient `SELECT DISTINCT`
when it wasn't even needed (because the query wouldn't return duplicates
anyway - duplicates were only added by putting a user on top of the
list).
上级 65bf7e0d
......@@ -18,15 +18,14 @@ class AutocompleteController < ApplicationController
if params[:search].blank?
# Include current user if available to filter by "Me"
if params[:current_user].present? && current_user
@users = @users.where.not(id: current_user.id)
@users = [current_user, *@users]
end
if params[:author_id].present?
author = User.find_by_id(params[:author_id])
@users = [author, *@users] if author
@users = [author, *@users].uniq if author
end
@users.uniq!
end
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册