# (שימוש לרעה ב-bumped\_at להשגת מיון דמוי Reddit

**URL:** <https://meta.discourse.org/t/ab-using-bumped-at-to-achieve-reddit-like-sorting/184003>\
**Category:** Development\
**Created:** [22 במרץ,‏ 2021,‏ 8:25am UTC](https://meta.discourse.org/t/ab-using-bumped-at-to-achieve-reddit-like-sorting/184003 "2021-03-22T08:25:18Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![hyd504](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hyd504/32/177122_2.png) [@hyd504](https://meta.discourse.org/u/hyd504)\
**Post date:** [22 במרץ,‏ 2021,‏ 8:25am UTC](https://meta.discourse.org/t/ab-using-bumped-at-to-achieve-reddit-like-sorting/184003/1 "2021-03-22T08:25:18Z")

</div>

I am running a news/political discussion forum on discourse. The issue I am seeing is that the default sorting that discourse comes with results in complete chaos for my use case since the age of topic matters a lot. For a forum such as mine, Reddit style sorting makes the most sense however my understanding is that there is no straightforward way of achieving it.

I am wondering if it is possible to (ab)use bumped\_at to achieve Reddit sorting by doing something like:

```plaintext
def topic_hotness(created_at, like_count)
   /**
      This function translates created_at and like_count
      into bumped_at date using a mathematical formula
      similar to the one used by Reddit. Consider bumped_at
      as a date until which we need the topic to be in the top 10
      given its creation date and number of likes.
   */
end

add_model_callback(Topic, :before_save) do
   self.bumped_at = topic_hotness(self.created_at, self.like_count)
end

```

Is this going to work? And what features might it break which would need to be addressed. I saw somewhere in the discourse code base where an exception is thrown if bumped\_at is in the future. Depending on the formula, using this scheme can result in bumped\_at dates in the future. Any thoughts?

---

_[View the full topic](https://meta.discourse.org/t/ab-using-bumped-at-to-achieve-reddit-like-sorting/184003)._
