Ask A Question

Notifications

You’re not receiving notifications from this thread.

how do implement a rails popularity/trending algorithm

Samuel Janes asked in Rails

I'm making a web app and I want to sort through a model based on popularity/trendiness, kind of like reddit/hacker news.
I want to determine the popularity based on the count of comments, likes, and impression divided by the creation date from the current world time, or some better algortihm.
How would I implement that

Reply

Hey Samuel, I haven't done this recently, but it's a fun one that I should definitely do a screencast on sometime.

Check out this post. He links to a couple other related posts that are worth reading and implements a SQL query to do ranking. You can probably do something similar to this: http://www.akitaonrails.com/2016/10/31/ruby-on-rails-implementation-of-a-proper-ranking-popularity-system

Reply

If you haven't seen it already, check out the reddit "hot" algorithm

https://gist.github.com/nanosplit/db42e507c5d1d984b664868db10a3669

There's also a thread I found on reddit that talks about it and helps explain what it's doing:

https://m.reddit.com/r/math/comments/vmxvf/how_is_this_algorithm_for_the_reddit_hot_ranking/?ref=search_posts

Reply

v

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.