In short: you have created an extreme ice storm in which posts simply freeze to death after 48 hours.
There is nothing "wrong" with your algorithm, but you let the scores "cool down" too fast.
Imagine that a post is two days old (then the if
clause) is triggered. In that case x = 1
, and in that case the exp(..)
will result in:
>>> exp(-8)
0.00033546262790251185
That's right. 0.00033...
, or 0.03%
. So that means if your post got 10 000 votes, the base score is 9.21
, and after this multiplication, only:
>>> log(10000) * exp(-8)
0.003089724985059729
Yes, the cooling scheme should ensure that eventually everything cools down, but not by putting the posts into an ice storm.
You can for example remove the 8*
factor. This means that the second day, we multiply the score with ~0.37
or 36.79%. You can experiment a bit with the factor or some other parts of the cooling scheme and thus let the posts cool down nicely.
Another aspect is that the time is quite descritized: you count the number of days. But that means that as long as the second day is not entirely over, the value is 1. But from the moment the second day is over, the "temperature" of the post makes a gigantic drop. You could use the number of seconds and divide by 86'400 instead:
timeDiff = (now - self.post.date).total_seconds() / 86400 # continuum