Has anyone managed to implement the reddit hot ranking?

Does anyone know a way to implement hot ranking into bubble for sorting repeating group

votes - downvotes / time since created?

similar to reddit hot ranking?

Hi @anderson.gomes,

Cool idea! Here’s how I’d set that up:

Database setup

  1. Add two fields, with type number, to the thing you want to rank by hotness.
  2. Call them “hotness” and “score” and default them to 0

Backend setup

  1. Create a backend trigger
  2. When Post Before Change score is not Post now score
  3. Run the hotness workflow at the bottom of this post

Frontend setup

  1. When upvote button (or downvote button) is clicked → parentgroup’sPost’sScore = parentgroup’sPost’sScore + 1 (or minus 1 if it’s a downvote)
  2. When the score changes, it’ll cause the backend trigger to fire and update the hotness.

If you don’t mind a little math… here’s Reddit’s hotness formula…

Low-code speak:
time(seconds) = Current datetime - Upvote datetime: formatted as seconds
score = upvotes - downvotes
sign = 1 (if score is postive)
sign = -1 (if score is negative)
sign = 0 (if score is 0)
order = log(max(abs(s), 1), 10) **Sorry that’s just math
hotness = round(sign * order + seconds / 45000, 7)

The python code and medium article if you’re interested:

You could also schedule an API workflow to fire instead of a trigger.

Hope this helps!


Thanks for the help, I’ll try to do it that way.

This topic was automatically closed after 70 days. New replies are no longer allowed.