From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 1/2] statistics: spamscores: fix total count when there is outgoing spam
Date: Mon, 27 Mar 2023 16:53:54 +0200 [thread overview]
Message-ID: <20230327145355.444827-1-d.csapak@proxmox.com> (raw)
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
next reply other threads:[~2023-03-27 14:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 14:53 Dominik Csapak [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230327145355.444827-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox