[pmg-devel] [PATCH pmg-api] extended fix #1974: traffic_stat_graph: go through all entries

Alexander Plank alexander.plank at siconnex.com
Thu Jun 6 14:54:56 CEST 2019


Extends a fix for #1974.
The commit cb609ca098823734dde590fcf42164f72bbfbf37 fixed the graph for postscreen_stat_graph.
The code from the above commit was adopted to fix the same error for traffic_stat_graph.

Signed-off-by: Alexander Plank <alexander.plank at siconnex.com>
---
 PMG/Statistic.pm | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/PMG/Statistic.pm b/PMG/Statistic.pm
index c2b103f..27b1166 100755
--- a/PMG/Statistic.pm
+++ b/PMG/Statistic.pm
@@ -901,24 +901,24 @@ sub traffic_stat_graph {
 	"GROUP BY index ORDER BY index";
 
     my $sth =  $rdb->{dbh}->prepare($cmd);
-
     $sth->execute ();
 
+	my $max_entry = int(($to - $from) / $span);
     while (my $ref = $sth->fetchrow_hashref()) {
-	@$res[$ref->{index}] = $ref;
+	my $i = $ref->{index};
+	$res->[$i] = $ref;
+	$max_entry = $i if $i > $max_entry;
     }
 
-    my $c = int (($to - $from) / $span);
-
-    for (my $i = 0; $i < $c; $i++) {
-	@$res[$i] //= {
+    for my $i (0..$max_entry) {
+	$res->[$i] //= {
 	    index => $i,
 	    count => 0, count_in => 0, count_out => 0,
 	    spamcount_in => 0, spamcount_out => 0,
 	    viruscount_in => 0, viruscount_out => 0,
 	    bounces_in => 0, bounces_out => 0 };
 
-	my $d = @$res[$i];
+	my $d = $res->[$i];
 
 	$d->{time} = $from + $i*$span - $timezone;
 	$d->{count} = $d->{count_in} + $d->{count_out};
-- 
2.21.0.windows.1




More information about the pmg-devel mailing list