I want to implement a ranking system on the website I was working on and decided to go with the Hacker News algorithm. My reasoning for choosing this algorithm is simply because it is described here .
I looked at this Python code (the language that I use to create my site), and could not understand how I implement it.
def calculate_score(votes, item_hour_age, gravity=1.8): return (votes - 1) / pow((item_hour_age+2), gravity)
Given the tables:
posts: id | title | time_submitted votes: id | postid | userid | score
How can I extract data from a database? The ideal solution (the most effective) would be to build a MySQL query to get the first 10 posts ranked using the algorithm. But, given that Hacker News has implemented it in Arc, it seems to me that they pull out all the messages and then run them through the algorithm to rank them.
Reddit also comes to mind for this ... They use a non-relational database schema, so I would suggest that they, like Hacker News, perform ranking in their code, not in the database.
How do you implement this?
EDIT: A single post can have many votes, as I would like to register which user votes on which post.
source share