FIX: make sure the best post is not the worst

By default Postgres returns NULLs first when sorting in a descending order. As a result, best_post() would often actually return the "worst" post of the topic. And it was then included in digest emails in "popular posts".
This commit is contained in:
Nick Ivanter 2016-04-19 13:18:58 +03:00
parent 3a641033cb
commit bc6862d82d
1 changed files with 1 additions and 1 deletions

View File

@ -245,7 +245,7 @@ class Topic < ActiveRecord::Base
end
def best_post
posts.order('score desc').limit(1).first
posts.order('score desc nulls last').limit(1).first
end
def has_flags?