Hacker News new | ask | show | jobs
by mdoliwa 1710 days ago
Not sure where I found it, but I have it coded like this:

scope :ranked, -> { select('posts.*, ((posts.upvotes_count + 1) / POWER(EXTRACT(EPOCH FROM (NOW() - posts.published_at)), 1.8)) AS rank').order('rank DESC') }

1 comments

That's almost the HN formula. Make sure your age is calculated as hours.