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:
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?