Skip to content

Commit 2dedd2b

Browse files
committed
When a user context is present, priortize all their posts ahead of
just the topic's OP before adding more.
1 parent ada7926 commit 2dedd2b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

lib/search.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ def posts_query(limit)
157157
.order("TS_RANK_CD(post_search_data.search_data, #{ts_query}) DESC")
158158
.order("topics.bumped_at DESC")
159159

160-
161-
162-
163160
if secure_category_ids.present?
164161
posts = posts.where("(categories.id IS NULL) OR (NOT categories.secure) OR (categories.id IN (?))", secure_category_ids)
165162
else
@@ -181,7 +178,15 @@ def ts_query
181178
end
182179

183180
def topic_search
184-
posts_query(@limit).where(post_number: 1).each do |p|
181+
182+
# If we have a user filter, search all posts by default with a higher limit
183+
posts = if @search_context.present? and @search_context.is_a?(User)
184+
posts_query(@limit * 3)
185+
else
186+
posts_query(@limit).where(post_number: 1)
187+
end
188+
189+
posts.each do |p|
185190
@results.add_result(SearchResult.from_post(p))
186191
end
187192
end

0 commit comments

Comments
 (0)