HACKER Q&A
📣 LeviathanCoding

How can I make a constantly-updating hotlist like HN?


I'm wanting to make a web app where there is a hotlist that will display trending topics first, kind of like how HN works.

I am using MongoDB for this and the data that effects each item is VIEWS, REVIEWS, and LIKES.

How can I calculate by how many likes, views, and reviews an item is getting to test if they are trending or not?


  👤 gus_massa Accepted Answer ✓
HN uses upvotes/(time_in_hours+1)^1.6*a_lot_of_penalties , where 1.6 is a number that may be changed by the mods without announcement. Comments are ignore, unless the post has too many comment and in this case HN adds a penalty. Flagging also adds a penalty once enough users flagged the post. And there are also other manual, and automatic penalties. Most details are secret and are part of the secret sauce.

You can create your own methods, but it's a editorial decisions. For example:

* Does comments move the post up, down, or not at all. Here in HN the idea is that too many comments is a sign of a flamewar, so one there are too many, it adds a penalty, but the mods may remove it.

* Is 1.6 the best exponent? A smaller number make popular post stay in the front page forever, a bigger value make recent bad post get too easy to the front page. Is 1.6 the best exponent? Nobody know. My guess is that it was chosen by experimentation until the got the result they like the best. And there is an alternative page https://news.ycombinator.com/best with another exponent (or something more strange).

* Number of views are ignored here, but it may be a good idea for other sites.


👤 markus_zhang
I guess it's subjective. I'd use some simple algorithms to calculate the rank.

From the top of my head, comments should take the biggest weight, likes next and view the smallest one. Basically the more actions users have to perform, the better rank the post gets.

But don't forget that views probably can be excluded from the equation as it is related to the other two. So either you drop view, or just use view. However, closer analysis would be needed (e.g. factor analysis, or PCA) to figure out the relationship.