Story: when calculating hotness, always penalize downvotes
This commit is contained in:
parent
7975da374f
commit
79964100bb
|
@ -187,15 +187,20 @@ class Story < ActiveRecord::Base
|
||||||
def calculated_hotness
|
def calculated_hotness
|
||||||
base = self.tags.map{|t| t.hotness_mod }.sum
|
base = self.tags.map{|t| t.hotness_mod }.sum
|
||||||
|
|
||||||
# give a story's comment votes some weight (unless the hotness mod is
|
# give a story's comment votes some weight, ignoring submitter's comments
|
||||||
# negative), but ignore the story submitter's own comments
|
cpoints = self.comments.
|
||||||
|
where("user_id <> ?", self.user_id).
|
||||||
|
select(:upvotes, :downvotes).
|
||||||
|
map{|c|
|
||||||
if base < 0
|
if base < 0
|
||||||
cpoints = 0
|
# in stories already starting out with a bad hotness mod, only look
|
||||||
|
# at the downvotes to find out if this tire fire needs to be put out
|
||||||
|
c.downvotes * -0.5
|
||||||
else
|
else
|
||||||
cpoints = self.comments.where("user_id <> ?", self.user_id).
|
c.upvotes + 1 - c.downvotes
|
||||||
select(:upvotes, :downvotes).map{|c| c.upvotes + 1 - c.downvotes }.
|
|
||||||
inject(&:+).to_f * 0.5
|
|
||||||
end
|
end
|
||||||
|
}.
|
||||||
|
inject(&:+).to_f * 0.5
|
||||||
|
|
||||||
# mix in any stories this one cannibalized
|
# mix in any stories this one cannibalized
|
||||||
cpoints += self.merged_stories.map{|s| s.score }.inject(&:+).to_f
|
cpoints += self.merged_stories.map{|s| s.score }.inject(&:+).to_f
|
||||||
|
|
Loading…
Reference in a new issue