mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: order latest was broken
This commit is contained in:
parent
a4ace3f08e
commit
664e2209e5
1 changed files with 5 additions and 3 deletions
|
@ -522,11 +522,13 @@ class Search
|
|||
|
||||
def aggregate_search(opts = {})
|
||||
|
||||
min_or_max = @order == :latest ? "max" : "min"
|
||||
|
||||
post_sql = posts_query(@limit, aggregate_search: true,
|
||||
private_messages: opts[:private_messages])
|
||||
.select('topics.id', 'min(post_number) post_number')
|
||||
.group('topics.id')
|
||||
.to_sql
|
||||
.select('topics.id', "#{min_or_max}(post_number) post_number")
|
||||
.group('topics.id')
|
||||
.to_sql
|
||||
|
||||
# double wrapping so we get correct row numbers
|
||||
post_sql = "SELECT *, row_number() over() row_number FROM (#{post_sql}) xxx"
|
||||
|
|
Loading…
Reference in a new issue