开发者

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

开发者 https://www.devze.com 2023-04-07 03:06 出处:网络
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 mod开发者_开发知识库ule.)Here\'

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 mod开发者_开发知识库ule.)


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号