What's the best way of implementing a 'popular content' display?

和自甴很熟 提交于 2020-01-04 03:54:11

问题


How do I show a list of 'most popular (articles|posts|whatever) for a period such as the past day? (Essentially replicate the functionality of the Radioactivity Drupal module.)


回答1:


Here's what I would do:

  1. If you're not already, sign up for Google Analytics and add the google analytics javascript to each of your pages. This will track view count for you.
  2. Using the google data API library, fetch the information you want. For example, you could ask for the most popular pages on your site in the last day.
  3. Once you have a script that fetches the data you're interested in, you can use django-celery to schedule a periodic task (e.g. once an hour, once a day) to run your script and cache the output in your database for display on your site.



回答2:


Maybe you could decide which posts are popular based on the number of comments on those posts




回答3:


http://popularposts.benguild.com/ ... that's why I built this. It just receives data from Google Analytics scheduled emails and reminds you to extend them before they stop working after a year.



来源:https://stackoverflow.com/questions/7546152/whats-the-best-way-of-implementing-a-popular-content-display

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