FIX: Stop aggregating likes

This commit is contained in:
Sam 2015-09-18 17:49:57 +10:00
parent 01782affe2
commit 681334701d
1 changed files with 9 additions and 1 deletions

View File

@ -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"