3 ms·
Really curious what the algorithm looks like that moves stories up-and-down the page. Anyone taken the time to unravel the great mystery behind it?
by bprater 18y ago
Really curious what the algorithm looks like that moves stories up-and-down the page.
Anyone taken the time to unravel the great mystery behind it?
- bprater 18y agoWoot! found the answer on a reddit thread. Copied and pasted from a commenter: def hot(ups, downs, date): s = score(ups, downs) order = log(max(abs(s), 1), 10) sign = 1 if s > 0 else -1 if s < 0 else 0 seconds = epoch_seconds(date) - 1134028003 return round(order + sign * seconds / 45000, 7) "score" is just (upvotes - downvotes). This is then log normalised. "seconds" is the number of seconds that have elapsed since around 1.46am on 8th Dec 2005. "sign" just ensures a positive value. 45000 seconds is 12.5 hours. I don't understand.... that looks like hotness increases the older the story is. I know brackets aren't needed but they help readability!"
- mrkurt 18y agoThere's a PGSQL "hot" function as well: http://code.reddit.com/browser/sql/functions.sql http://code.reddit.com/browser/sql/functions.sql
- aston 18y agoseconds is a number that grows as time progresses, meaning newer stories will always have a higher seconds score than older ones. The sign is included so that the time component hurts, not helps stories that are rated negative. The consequence of which is that newer negative stories are less hot than older negative stories. Also, the gap between positive 1 and negative 1 on reddit is HUGE hotness-wise.