From 4d78f29a7b822231bce8d557f18b644ed5deaf73 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 25 Nov 2024 11:04:53 +0000 Subject: [Minor] Some display/adding fixes --- lualib/rspamadm/fuzzy_stat.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lualib/rspamadm') 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 -- cgit v1.2.3