Last active
August 29, 2015 14:25
-
-
Save heri/815a2aca6727c10b47d3 to your computer and use it in GitHub Desktop.
quarantine subredits
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
# quarantine algorithm for subreddit | |
# see https://medium.com/product-dot-io/reddit-empowering-the-community-5c0ce2c266e2 | |
def quarantine(number_of_reports, number_of_content) | |
# number of content is number of comments and submissions with positive upvotes | |
s = number_of_reports - Math.log10(number_of_content) | |
order = Math.log10([s.abs, 1].max) | |
sign = if s > 0 | |
1 | |
elsif s < 0 | |
-1 | |
else | |
0 | |
end | |
# Time.now.to_i converts ruby timestamp to seconds in Epoch | |
seconds = Time.now.to_i - 1134028003 | |
# rating function | |
return Math.round(sign * order + seconds / 45000, 7) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment