pull down to refresh
Wouldn't you be taking the exponent of a negative, so it would only shrink down to zero at some point?
I see. You're wanting to update the sum incrementally by adding the right-most component each time. Newer zaps have a larger zap_time and thus a higher weight. But the weights are enormous because of the exponent.
Wasn't quite sure what you meant by only having to store the time of the last zap and the moving sum though.
I think you'd have to update the rank of all the other items at the same time that item gets zapped, otherwise item 's rank relative to other items might actually go down, because its old rank gets down-weighted via the exponent.
(As an example, imagine item gets a zap of just 1 sat. Its old rank gets down-weighted for time, by the increase from the 1 sat is negligible.)
I think I've got a static (time invariant) sort key for this. The exponent is huge and I can't store a log value because negative zap amounts are a thing. I have to store the time of the last zap along with the moving sum in order to incrementally update the sum right, but it isn't that bad (especially for how cool it is).