]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Correct EMA time calculations 3091/head
authorBuGi <bugi@nicelan.tk>
Wed, 16 Oct 2019 09:59:49 +0000 (11:59 +0200)
committerBuGi <bugi@nicelan.tk>
Wed, 16 Oct 2019 16:23:01 +0000 (18:23 +0200)
src/plugins/lua/reputation.lua

index 4276f23cc27b57bda1b3d5c9988f26f22f0c4ab9..6b43c7fb47d908d595a100e39cf99f5a842148b4 100644 (file)
@@ -865,8 +865,8 @@ local function reputation_redis_init(rule, cfg, ev_base, worker)
     local last_value = tonumber(redis.call('HGET', KEYS[1], 'v' .. '{= w.name =}'))
     local window = {= w.time =}
     -- Adjust alpha
-    local time_diff = now - last_value
-    if time_diff > 0 then
+    local time_diff = now - last
+    if time_diff < 0 then
       time_diff = 0
     end
     local alpha = 1.0 - math.exp((-time_diff) / (1000 * window))