A Digg-like rotating homepage of popular content, how to include date as a factor?

Posted by Ferdy on Stack Overflow See other posts from Stack Overflow or by Ferdy
Published on 2010-04-26T18:39:11Z Indexed on 2010/04/26 18:43 UTC
Read the original article Hit count: 303

Filed under:
|
|
|

I am building an advanced image sharing web application. As you may expect, users can upload images and others can comments on it, vote on it, and favorite it. These events will determine the popularity of the image, which I capture in a "karma" field.

Now I want to create a Digg-like homepage system, showing the most popular images. It's easy, since I already have the weighted Karma score. I just sort on that descendingly to show the 20 most valued images.

The part that is missing is time. I do not want extremely popular images to always be on the homepage. I guess an easy solution is to restrict the result set to the last 24 hours. However, I'm also thinking that in order to keep the image rotation occur throughout the day, time can be some kind of variable where its offset has an influence on the image's sorting.

Specific questions:

  • Would you recommend the easy scenario (just sort for best images within 24 hours) or the more sophisticated one (use datetime offset as part of the sorting)? If you advise the latter, any help on the mathematical solution to this?
  • Would it be best to run a scheduled service to mark images for the homepage, or would you advise a direct query (I'm using MySQL)
  • As an extra note, the homepage should support paging and on a quiet day should include entries of days before in order to make sure it is always "filled"

I'm not asking the community to build this algorithm, just looking for some advise :)

© Stack Overflow or respective owner

Related posts about web-development

Related posts about sorting