From: Dominik Csapak Date: Tue, 3 Mar 2020 08:33:35 +0000 (+0100) Subject: fix #2622: include all spam levels in total spam statistic X-Git-Url: https://git.proxmox.com/?p=pmg-api.git;a=commitdiff_plain;h=f7f689cecd05e64bd2a19e5b3f394dea2d3901b8 fix #2622: include all spam levels in total spam statistic by using 'LIMIT 10' for the spamlevels, we only got the first 10 spamlevels back from the database. This is only ok if there are only <= 10 different spamlevels in the database, but not if there are more, as then the bucket for spamlevel >= 10 missed entries. The call site of this uses the combined spam count of this query result for calculating the 'rest' (meaning the mails with spam level 0), but this is obviously wrong if not all spamlevels are counted so simply return all available levels. Signed-off-by: Dominik Csapak --- diff --git a/src/PMG/Statistic.pm b/src/PMG/Statistic.pm index b00fed4..6d27930 100755 --- a/src/PMG/Statistic.pm +++ b/src/PMG/Statistic.pm @@ -431,7 +431,7 @@ sub total_spam_stat { my $sth = $rdb->{dbh}->prepare("SELECT spamlevel, COUNT(spamlevel) AS count FROM CStatistic " . "WHERE virusinfo IS NULL and time >= ? AND time < ? AND ptime > 0 AND spamlevel > 0 " . - "GROUP BY spamlevel ORDER BY spamlevel LIMIT 10"); + "GROUP BY spamlevel ORDER BY spamlevel"); $sth->execute($from, $to); my $res = $sth->fetchall_arrayref({});