问题
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:
- 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.
- 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.
- 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