The ranking is implemented in a rather complicated way for performance reasons:
- First there are SQL functions which calculate the rank for a specific post or comment (defined here)
- These SQL functions are used by a scheduled task which updates post ranks at a regular interval (defined here)
- Then there are the database tables which store the calculated rank (eg
post.hot_rank
) - Also the API parameters to specify the requested sort, and preferences for default sort options etc
- These params are used in the post listing db query to sort posts by the given rank field (here)