Story: use newest created_at of all merged stories for calculating hotness
we already take their points, but if they have a much newer created_at and we've been moved off the front page, points won't save us. use their created_at to be fresher. should fix #300
This commit is contained in:
parent
641cc4cc1f
commit
cb300450fb
|
@ -206,8 +206,15 @@ class Story < ActiveRecord::Base
|
|||
sign = 0
|
||||
end
|
||||
|
||||
return -((order * sign) + base +
|
||||
((self.created_at || Time.now).to_f / HOTNESS_WINDOW)).round(7)
|
||||
# if any newer stories were merged into us, use the newest created_at to
|
||||
# take its place on the front page
|
||||
tcreated_at = (self.created_at || Time.now).to_f
|
||||
if (mtca = self.merged_stories.map{|ts| ts.created_at.to_f }.max) &&
|
||||
mtca > tcreated_at
|
||||
tcreated_at = mtca
|
||||
end
|
||||
|
||||
return -((order * sign) + base + (tcreated_at / HOTNESS_WINDOW)).round(7)
|
||||
end
|
||||
|
||||
def can_be_seen_by_user?(user)
|
||||
|
|
Loading…
Reference in a new issue