search: optimize ?search[user_name]=... searches.
Optimize searches using the `search[user_name]=...` URL parameter. If we're not doing a wildcard search, then do a regular user lookup, which generates better SQL.
This commit is contained in:
@@ -397,7 +397,12 @@ module Searchable
|
|||||||
|
|
||||||
model = association.klass
|
model = association.klass
|
||||||
if model == User && params["#{attr}_name"].present?
|
if model == User && params["#{attr}_name"].present?
|
||||||
relation = relation.where(attr => User.search(name_matches: params["#{attr}_name"]).reorder(nil))
|
name = params["#{attr}_name"]
|
||||||
|
if name.include?("*")
|
||||||
|
relation = relation.where(attr => User.search(name_matches: name).reorder(nil))
|
||||||
|
else
|
||||||
|
relation = relation.where(attr => User.find_by_name(name))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if model == Post && params["#{attr}_tags_match"].present?
|
if model == Post && params["#{attr}_tags_match"].present?
|
||||||
|
|||||||
Reference in New Issue
Block a user