From c151fbeeb8b53153a67044c9752525e960ec8e4d Mon Sep 17 00:00:00 2001 From: joshua stein Date: Thu, 1 Jan 2015 10:25:14 -0600 Subject: [PATCH] better tag hotness mod calculation --- app/models/story.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/story.rb b/app/models/story.rb index f73dc8c..6836115 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -132,9 +132,9 @@ class Story < ActiveRecord::Base end def calculated_hotness - base = 10 + base = 0 self.tags.select{|t| t.hotness_mod != 0 }.each do |t| - base -= t.hotness_mod + base += t.hotness_mod end # give a story's comment votes some weight, but ignore the story @@ -144,7 +144,7 @@ class Story < ActiveRecord::Base inject(&:+).to_i # don't immediately kill stories at 0 by bumping up score by one - order = Math.log([ (score + 1).abs + cpoints, 1 ].max, base) + order = Math.log([ (score + 1).abs + cpoints, 1 ].max, 10) if score > 0 sign = 1 elsif score < 0 @@ -156,7 +156,7 @@ class Story < ActiveRecord::Base # TODO: as the site grows, shrink this down to 12 or so. window = 60 * 60 * 24 - return -((order * sign) + (self.created_at.to_f / window)).round(7) + return -((order * sign) + base + (self.created_at.to_f / window)).round(7) end def can_be_seen_by_user?(user)