]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #2622: include all spam levels in total spam statistic
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 3 Mar 2020 08:33:35 +0000 (09:33 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 3 Mar 2020 09:11:32 +0000 (10:11 +0100)
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 <d.csapak@proxmox.com>
src/PMG/Statistic.pm

index b00fed40acfbad7d8e741bbb087e6be3935b7c58..6d279301e7559037b6fe2ec4e9b0ae517791bcec 100755 (executable)
@@ -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({});