FEATURE: add name and username to search within topic

This commit is contained in:
Sam Saffron 2014-09-20 12:57:16 +10:00
parent 68e56db61c
commit 05eff38f34
1 changed files with 2 additions and 1 deletions

View File

@ -255,7 +255,8 @@ class Search
.where("topics.archetype <> ?", Archetype.private_message) .where("topics.archetype <> ?", Archetype.private_message)
if @search_context.present? && @search_context.is_a?(Topic) if @search_context.present? && @search_context.is_a?(Topic)
posts = posts.where("posts.raw ilike ?", "%#{@term}%") posts = posts.joins('JOIN users u ON u.id = posts.user_id')
posts = posts.where("posts.raw || ' ' || u.username || ' ' || u.name ilike ?", "%#{@term}%")
else else
posts = posts.where("post_search_data.search_data @@ #{ts_query}") posts = posts.where("post_search_data.search_data @@ #{ts_query}")
end end