From 2b00750d9ab32004efd56e11a55a673ac8844684 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 12 May 2023 11:04:04 +0100 Subject: [Fix] More fixes to fuzzystat --- lualib/rspamadm/fuzzy_stat.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lualib/rspamadm') diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua index 47b780a09..85af32d28 100644 --- a/lualib/rspamadm/fuzzy_stat.lua +++ b/lualib/rspamadm/fuzzy_stat.lua @@ -57,10 +57,14 @@ local function add_data(target, src) end local function print_num(num) - if opts['n'] or opts['number'] then - return tostring(num) + if num then + if opts['n'] or opts['number'] then + return tostring(num) + else + return rspamd_util.humanize_number(num) + end else - return rspamd_util.humanize_number(num) + return 'na' end end @@ -301,8 +305,10 @@ return function(args, res) if key_stat.flags then print('') print('\tFlags stat:') - for flag,v in ipairs(key_stat.flags) do - print(string.format('\t%s', flag)) + for flag,v in pairs(key_stat.flags) do + print(string.format('\t[%s]:', flag)) + -- Remove irrelevant fields + v.checked = nil print_stat(v, '\t\t') print('') end @@ -331,7 +337,7 @@ return function(args, res) print('') print('IPs statistics:') - local sorted_ips = sort_hash_table(res_ips, opts) + local sorted_ips = sort_hash_table(res_ips, opts, 'ip') for _, v in ipairs(sorted_ips) do print(string.format('%s', v['ip'])) print_stat(v['data'], '\t') -- cgit v1.2.3