Popularity Algorithm - SQL / Django

Posted by RadiantHex on Stack Overflow See other posts from Stack Overflow or by RadiantHex
Published on 2010-03-22T23:38:15Z Indexed on 2010/03/22 23:41 UTC
Read the original article Hit count: 361

Filed under:
|
|
|
|

Hi folks,

I've been looking into popularity algorithms used on sites such as Reddit, Digg and even Stackoverflow.

Reddit algorithm:

t = (time of entry post) - (Dec 8, 2005)
x = upvotes - downvotes

y = {1 if x > 0, 0 if x = 0, -1 if x < 0)
z = {1 if x < 0, otherwise x}

log(z) + (y * t)/45000

I have always performed simple ordering within SQL, I'm wondering how I should deal with such ordering.

Should it be used to define a table, or could I build an SQL with the ordering within the formula (without hindering performance)?

I am also wondering, if it is possible to use multiple ordering algorithms in different occasions, without incurring into performance problems.


I'm using Django and PostgreSQL.

Help would be much appreciated! ^^

© Stack Overflow or respective owner

Related posts about sql

Related posts about popularity