commit 9b9e41c: [Fix] Correct EMA time calculations

BuGi bugi at nicelan.tk
Wed Oct 16 16:56:05 UTC 2019


Author: BuGi
Date: 2019-10-16 11:59:49 +0200
URL: https://github.com/rspamd/rspamd/commit/9b9e41ca9c8a3d86b9bee9ef7929c131caeaa530 (refs/pull/3091/head)

[Fix] Correct EMA time calculations

---
 src/plugins/lua/reputation.lua | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua
index 4276f23cc..6b43c7fb4 100644
--- a/src/plugins/lua/reputation.lua
+++ b/src/plugins/lua/reputation.lua
@@ -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))


More information about the Commits mailing list