mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -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 = {})
|
def aggregate_search(opts = {})
|
||||||
|
|
||||||
|
min_or_max = @order == :latest ? "max" : "min"
|
||||||
|
|
||||||
post_sql = posts_query(@limit, aggregate_search: true,
|
post_sql = posts_query(@limit, aggregate_search: true,
|
||||||
private_messages: opts[:private_messages])
|
private_messages: opts[:private_messages])
|
||||||
.select('topics.id', 'min(post_number) post_number')
|
.select('topics.id', "#{min_or_max}(post_number) post_number")
|
||||||
.group('topics.id')
|
.group('topics.id')
|
||||||
.to_sql
|
.to_sql
|
||||||
|
|
||||||
# double wrapping so we get correct row numbers
|
# double wrapping so we get correct row numbers
|
||||||
post_sql = "SELECT *, row_number() over() row_number FROM (#{post_sql}) xxx"
|
post_sql = "SELECT *, row_number() over() row_number FROM (#{post_sql}) xxx"
|
||||||
|
|
Loading…
Reference in a new issue