* [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
* [pmg-devel] [PATCH pmg-api 2/2] statistics: use localized day span for spamscores
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 ` Dominik Csapak
2023-03-28 7:40 ` Dominik Csapak
0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2023-03-27 14:53 UTC (permalink / raw)
To: pmg-devel
the total info we use is also the localized day span so we have to use
that here too. Alternatively, we could use the non localized one on
both.
Signed-off-by: Dominik Csapak <d.csapak@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 99f96cf..024e550 100755
--- a/src/PMG/Statistic.pm
+++ b/src/PMG/Statistic.pm
@@ -428,7 +428,7 @@ sub total_mail_stat {
sub total_spam_stat {
my ($self, $rdb) = @_;
- my ($from, $to) = $self->timespan();
+ my ($from, $to) = $self->localdayspan();
my $sth = $rdb->{dbh}->prepare(
"SELECT spamlevel, COUNT(spamlevel) AS count FROM CStatistic"
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api 2/2] statistics: use localized day span for spamscores
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
0 siblings, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-03-28 7:40 UTC (permalink / raw)
To: pmg-devel
disregard this, i believe we have to go in the reverse direction
(use timespan instead of localdayspan), but further investigation is
necessary...
^ 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