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:
parent
73f93ba09d
commit
606f5c9849
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue