mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: topic search order
When using the full page search and filtering down to a specific topic, the sort order was overwritten to by by "post_number". This was confusing because we allow different type of sort order in the full search page. This fixes it by only sorting by post_number when there's no "global" sort order defined. Since the "new topic map" uses the search endpoint behind the scene, this also fixes the "most likes" popup. Context - https://meta.discourse.org/t/searching-order-seems-to-be-broken-when-searching-in-topic/312303
This commit is contained in:
@ -1191,9 +1191,9 @@ class Search
|
||||
|
||||
posts.where("topics.category_id in (?)", category_ids)
|
||||
elsif is_topic_search
|
||||
posts.where("topics.id = ?", @search_context.id).order(
|
||||
"posts.post_number #{@order == :latest ? "DESC" : ""}",
|
||||
)
|
||||
posts = posts.where("topics.id = ?", @search_context.id)
|
||||
posts = posts.order("posts.post_number ASC") unless @order
|
||||
posts
|
||||
elsif @search_context.is_a?(Tag)
|
||||
posts =
|
||||
posts.joins("LEFT JOIN topic_tags ON topic_tags.topic_id = topics.id").joins(
|
||||
|
Reference in New Issue
Block a user