diff options
author | BuGi <bugi@nicelan.tk> | 2019-10-16 11:59:49 +0200 |
---|---|---|
committer | BuGi <bugi@nicelan.tk> | 2019-10-16 18:23:01 +0200 |
commit | 9b9e41ca9c8a3d86b9bee9ef7929c131caeaa530 (patch) | |
tree | 49fbdaa690bb3fe0aa2b345459078c66f691c97f /src/plugins | |
parent | 52d43acb2cfeeb65c05b9087d7c3e7555a8d04ce (diff) | |
download | rspamd-9b9e41ca9c8a3d86b9bee9ef7929c131caeaa530.tar.gz rspamd-9b9e41ca9c8a3d86b9bee9ef7929c131caeaa530.zip |
[Fix] Correct EMA time calculations
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/reputation.lua | 4 |
1 files 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)) |