FEATURE: added status:noreplies and status:archived to advanced search

This commit is contained in:
Sam
2014-10-18 14:54:11 +11:00
parent 840b68003c
commit cbc132eca9
3 changed files with 20 additions and 2 deletions

View File

@@ -142,6 +142,7 @@ class Search
private
def process_advanced_search!(term)
term.to_s.split(/\s+/).map do |word|
if word == 'status:open'
@status = :open
@@ -149,6 +150,12 @@ class Search
elsif word == 'status:closed'
@status = :closed
nil
elsif word == 'status:archived'
@status = :archived
nil
elsif word == 'status:noreplies'
@no_replies = true
nil
elsif word == 'order:latest'
@order = :latest
nil
@@ -263,8 +270,14 @@ class Search
if @status == :open
posts = posts.where('NOT topics.closed AND NOT topics.archived')
elsif @status == :archived
posts = posts.where('topics.archived')
elsif @status == :closed
posts = posts.where('topics.closed OR topics.archived')
posts = posts.where('topics.closed')
end
if @no_replies
posts = posts.where("topics.featured_user1_id IS NULL AND topics.last_post_user_id = topics.user_id")
end
# If we have a search context, prioritize those posts first