Permalink
Browse files

set hotness with score+1 so a single downvote doesn't kill it

  • Loading branch information...
jcs committed Dec 28, 2013
1 parent 4fe74ab commit 1e7dc17b568a57a39a4ceb6b4dc842ba80b581cf
Showing with 3 additions and 2 deletions.
  1. +3 −2 app/models/story.rb
View
@@ -245,7 +245,8 @@ def fetch_story_cache!
end
def calculated_hotness
order = Math.log([ score.abs, 1 ].max, 10)
# don't immediately kill stories at 0 by bumping up score by one
order = Math.log([ (score + 1).abs, 1 ].max, 10)
if score > 0
sign = 1
elsif score < 0
@@ -257,7 +258,7 @@ def calculated_hotness
# TODO: as the site grows, shrink this down to 12 or so.
window = 60 * 60 * 48
return -(order + (sign * (self.created_at.to_f / window))).round(7)
return -((order * sign) + (self.created_at.to_f / window)).round(7)
end
def score

0 comments on commit 1e7dc17

Please sign in to comment.