PERF: only use fulltext when searching for a user (I checked, it's enough)

This commit is contained in:
Régis Hanol
2015-11-04 23:04:37 +01:00
parent abeac7f681
commit 7e255a151b
2 changed files with 11 additions and 13 deletions

View File

@ -382,11 +382,12 @@ class Search
return if SiteSetting.hide_user_profiles_from_public && !@guardian.user
users = User.includes(:user_search_data)
.where("active = true AND user_search_data.search_data @@ #{ts_query("simple")}")
.references(:user_search_data)
.where("active = TRUE")
.where("user_search_data.search_data @@ #{ts_query("simple")}")
.order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END")
.order("last_posted_at DESC")
.limit(@limit)
.references(:user_search_data)
users.each do |user|
@results.add(user)