mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: Stop aggregating likes
This commit is contained in:
parent
01782affe2
commit
681334701d
1 changed files with 9 additions and 1 deletions
|
@ -524,11 +524,19 @@ class Search
|
|||
|
||||
min_or_max = @order == :latest ? "max" : "min"
|
||||
|
||||
post_sql = posts_query(@limit, aggregate_search: true,
|
||||
post_sql =
|
||||
if @order == :likes
|
||||
# likes are a pain to aggregate so skip
|
||||
posts_query(@limit, private_messages: opts[:private_messages])
|
||||
.select('topics.id', "post_number")
|
||||
.to_sql
|
||||
else
|
||||
posts_query(@limit, aggregate_search: true,
|
||||
private_messages: opts[:private_messages])
|
||||
.select('topics.id', "#{min_or_max}(post_number) post_number")
|
||||
.group('topics.id')
|
||||
.to_sql
|
||||
end
|
||||
|
||||
# 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