[pve-devel] [PATCH pmg-api] fix #2622: include all spem levels

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 3 10:02:10 CET 2020


subject: s/spem/spam/

On 3/3/20 9:33 AM, Dominik Csapak wrote:
> by using 'LIMIT 10' for the spamlevels, we only got the first
> 10 spamlevels back from the database (whatever they were)

"whatever they were" is misleading, as this is ordered, so the
top 10 should get returned, or?

> 
> this is only ok if there are only <= 10 different spamlevels in the database
> but not if there are more
> 
> the call site of this uses the combined spam count of this sub
> 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

hmm, sounds OK, this code is a classic imported from other git,
then imported from svn case - was this always an issue or did something
else change to make this one?

> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PMG/Statistic.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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({});
> 





More information about the pve-devel mailing list