When a user context is present, priortize all their posts ahead of

just the topic's OP before adding more.
This commit is contained in:
Robin Ward 2013-05-24 17:44:35 -04:00
parent ada79260b3
commit 2dedd2bd6e

View file

@ -157,9 +157,6 @@ class Search
.order("TS_RANK_CD(post_search_data.search_data, #{ts_query}) DESC")
.order("topics.bumped_at DESC")
if secure_category_ids.present?
posts = posts.where("(categories.id IS NULL) OR (NOT categories.secure) OR (categories.id IN (?))", secure_category_ids)
else
@ -181,7 +178,15 @@ class Search
end
def topic_search
posts_query(@limit).where(post_number: 1).each do |p|
# If we have a user filter, search all posts by default with a higher limit
posts = if @search_context.present? and @search_context.is_a?(User)
posts_query(@limit * 3)
else
posts_query(@limit).where(post_number: 1)
end
posts.each do |p|
@results.add_result(SearchResult.from_post(p))
end
end