aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm/fuzzy_stat.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lualib/rspamadm/fuzzy_stat.lua')
-rw-r--r--lualib/rspamadm/fuzzy_stat.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua
index 011f9d37c..c65a1a477 100644
--- a/lualib/rspamadm/fuzzy_stat.lua
+++ b/lualib/rspamadm/fuzzy_stat.lua
@@ -72,10 +72,16 @@ local function add_data(target, src)
end
elseif k == 'ratelimit' then
if not target.ratelimit then
- target.ratelimit = {}
+ target.ratelimit = {
+ cur = {
+ last = 0,
+ count = 0
+ }
+ }
end
-- Ratelimit is passed as {cur = count, last = time}
- target.ratelimit.cur = v
+ target.ratelimit.cur.count = v.cur + target.ratelimit.cur.count
+ target.ratelimit.cur.last = math.max(v.last, target.ratelimit.cur.last)
end
end
end
@@ -355,7 +361,7 @@ return function(args, res)
print(string.format('\tLimit: %s (%.2f per hour leak rate)',
print_num(key_stat.ratelimit.limit.burst), (key_stat.ratelimit.limit.rate or 0.0) * 3600))
print(string.format('\tCurrent: %s (%s last)',
- print_num(key_stat.ratelimit.cur), os.date('%c', key_stat.ratelimit.last)))
+ print_num(key_stat.ratelimit.cur.count), os.date('%c', key_stat.ratelimit.cur.last)))
print('')
end