experiment with factoring comment scores into story hotness

might keep an active story alive on the front page and bury a story
with a "comment graveyard"
This commit is contained in:
joshua stein 2014-12-09 10:07:36 -06:00
parent 73f93ba09d
commit 606f5c9849
2 changed files with 6 additions and 2 deletions

View file

@ -250,6 +250,8 @@ class Comment < ActiveRecord::Base
"downvotes = COALESCE(downvotes, 0) + #{downvote.to_i}, " <<
"confidence = '#{self.calculated_confidence}' WHERE id = " <<
"#{self.id.to_i}")
self.story.recalculate_hotness!
end
def gone_text

View file

@ -138,10 +138,12 @@ class Story < ActiveRecord::Base
end
# prevent the submitter's own comments from affecting the score
ccount = self.comments.where("user_id != ?", self.user_id).count
cpoints = self.comments.where("user_id <> ?",
self.user_id).select(:upvotes, :downvotes).map{|c|
c.upvotes - c.downvotes }.inject(&:+).to_i
# don't immediately kill stories at 0 by bumping up score by one
order = Math.log([ (score + 1).abs + ccount, 1 ].max, base)
order = Math.log([ (score + 1).abs + cpoints, 1 ].max, base)
if score > 0
sign = 1
elsif score < 0