Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chucai/28d11cd89bc30fffcfec1791fcad4353 to your computer and use it in GitHub Desktop.
Save chucai/28d11cd89bc30fffcfec1791fcad4353 to your computer and use it in GitHub Desktop.
Hacker News 排名算法的MYSQL函数实现
-- (p - 1) / (t + 2)^1.5
CREATE FUNCTION SP_POINTS(P SMALLINT(5), CREATED TIMESTAMP)
RETURNS TINYINT(3)
RETURN (P - 1) / POW(TIMESTAMPDIFF(HOUR, CREATED, NOW()) + 2, 1.5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment