2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

add search filter

This commit is contained in:
Sam 2014-05-16 00:31:45 +10:00
parent b2d6e2aa43
commit 90d7718103
3 changed files with 20 additions and 3 deletions

View file

@ -22,7 +22,9 @@ class TopicQuery
ascending
no_subcategories
no_definitions
status).map(&:to_sym)
status
search
).map(&:to_sym)
# Maps `order` to a columns in `topics`
SORTABLE_MAPPING = {
@ -259,6 +261,10 @@ class TopicQuery
result = result.where('topics.id in (?)', options[:topic_ids]).references(:topics)
end
if search = options[:search]
result = result.where("topics.id in (select pp.topic_id from post_search_data pd join posts pp on pp.id = pd.post_id where pd.search_data @@ #{Search.ts_query(search.to_s)})")
end
if status = options[:status]
case status
when 'open'