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:
parent
3a641033cb
commit
bc6862d82d
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue