FEATURE: search by user id or category id

FIX: more search results work if you open in new tab
FIX: carry context to full page search
This commit is contained in:
Sam
2015-07-10 16:31:28 +10:00
parent a2398c07f7
commit 4a5a2d869e
5 changed files with 48 additions and 13 deletions

View File

@@ -214,12 +214,12 @@ class Search
end
advanced_filter(/category:(.+)/) do |posts,match|
category_id = Category.find_by('name ilike ?', match).try(:id)
category_id = Category.find_by('name ilike ? OR id = ?', match, match.to_i).try(:id)
posts.where("topics.category_id = ?", category_id)
end
advanced_filter(/user:(.+)/) do |posts,match|
user_id = User.find_by('username_lower = ?', match.downcase).try(:id)
user_id = User.find_by('username_lower = ? OR id = ?', match.downcase, match.to_i).try(:id)
posts.where("posts.user_id = #{user_id}")
end