public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api 1/2] statistics: spamscores: fix total count when there is outgoing spam
@ 2023-03-27 14:53 Dominik Csapak
  2023-03-27 14:53 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: use localized day span for spamscores Dominik Csapak
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2023-03-27 14:53 UTC (permalink / raw)
  To: pmg-devel

We used 'count_in' as total value, but the spamlevel counts also
counted outgoing mails, so we could have weird stats with negative
mails.

To fix that, we simply count all mails, incoming and outgoing.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PMG/API2/Statistics.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PMG/API2/Statistics.pm b/src/PMG/API2/Statistics.pm
index 38c8d0c..051265b 100644
--- a/src/PMG/API2/Statistics.pm
+++ b/src/PMG/API2/Statistics.pm
@@ -1057,7 +1057,7 @@ __PACKAGE__->register_method ({
 
 	my $res = [];
 
-	my $count_in = $totalstat->{count_in};
+	my $total = $totalstat->{count_in} + $totalstat->{count_out};
 
 	my $levelcount = {};
 	my $spamcount = 0;
@@ -1070,11 +1070,11 @@ __PACKAGE__->register_method ({
 	    }
 	}
 
-	$levelcount->{0} = $count_in - $spamcount;
+	$levelcount->{0} = $total - $spamcount;
 
 	for (my $i = 0; $i <= 10; $i++) {
 	    my $count = $levelcount->{$i} // 0;
-	    my $ratio = $count_in ? $count/$count_in : 0;
+	    my $ratio = $total ? $count/$total : 0;
 	    push @$res, { level => $i, count => $count, ratio => $ratio };
 	}
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-28  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 14:53 [pmg-devel] [PATCH pmg-api 1/2] statistics: spamscores: fix total count when there is outgoing spam Dominik Csapak
2023-03-27 14:53 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: use localized day span for spamscores Dominik Csapak
2023-03-28  7:40   ` Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal