How to update content popularity scoring such as Hacker News algorithm?

倖福魔咒の 提交于 2019-12-02 08:01:34

OK. I have done it using different apps: First, you need to install either "dokterbob/django-popularity" on github or "thornomad/django-hitcount" to track how often a link is visited.

Second, you need to count how many votes (likes or favorites) an object receives. For that purpose, you can try "brosner/django-voting", "apgwoz/django-favorites".

Now you have to use this piece of code --django-populars to put them all together. I would recommend looking into this code first of all to see how it works to understand how to put together the needed components.

There's a number of ways to do this. One simple way is to number items sequentially, and start each item with a 'rank id' of its ID number. Whenever a post is rated up, increment its rank number (and vice-versa for down votes). Then, sort by rank number to order items correctly.

Another option is an exponential decay model, which requires periodic updates, but these can be piggy backed on votes, reducing the amount of batch-update work you have to do. I wrote an article about implementing that here. It's targeted at App Engine, but generally useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!