Created
October 8, 2014 07:38
-
-
Save forrestwilkins/273e7291849e623ab5ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.score(obj) | |
up_votes_weight = 0 | |
for vote in obj.votes.up_votes # recent votes on older posts have more weight | |
up_votes_weight += ((vote.created_at.to_date - obj.created_at.to_date).to_i / 2) + 1 | |
end # plus one for votes on recent posts to still get valued | |
_score = (up_votes_weight + (obj.comments.size / 2)) - | |
((obj.votes.down_votes.size.to_i * 2) + (Date.today - obj.created_at.to_date).to_i) | |
return _score | |
# also needs to check for clusters of recent votes, giving more | |
# weight to recent posts that are closer together in time, "hotness" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment