From: Vsevolod Stakhov Date: Sat, 13 May 2023 14:24:25 +0000 (+0100) Subject: [Minor] Show percentages X-Git-Tag: 3.6~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d932fb8f52b7e9e3226fc482329b471a5c27622a;p=thirdparty%2Frspamd.git [Minor] Show percentages --- diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua index 85af32d283..d0c14d2130 100644 --- a/lualib/rspamadm/fuzzy_stat.lua +++ b/lualib/rspamadm/fuzzy_stat.lua @@ -78,11 +78,21 @@ local function print_stat(st, tabs) end end if st['matched'] then - if st.matched_per_hour then - print(string.format('%sMatched: %s (%s per hour in average)', tabs, - print_num(st['matched']), print_num(st['matched_per_hour']))) + if st.checked and st.checked > 0 and st.checked <= st.matched then + local percentage = st.matched / st.checked * 100.0 + if st.matched_per_hour then + print(string.format('%sMatched: %s - %s percent (%s per hour in average)', tabs, + print_num(st['matched']), percentage, print_num(st['matched_per_hour']))) + else + print(string.format('%sMatched: %s - %s percent', tabs, print_num(st['matched']), percentage)) + end else - print(string.format('%sMatched: %s', tabs, print_num(st['matched']))) + if st.matched_per_hour then + print(string.format('%sMatched: %s (%s per hour in average)', tabs, + print_num(st['matched']), print_num(st['matched_per_hour']))) + else + print(string.format('%sMatched: %s', tabs, print_num(st['matched']))) + end end end if st['errors'] then