]> git.proxmox.com Git - pmg-api.git/commitdiff
extended fix #1974: traffic_stat_graph: go through all entries
authorAlexander Plank <alexander.plank@siconnex.com>
Thu, 6 Jun 2019 12:54:56 +0000 (14:54 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 7 Jun 2019 05:30:48 +0000 (07:30 +0200)
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@siconnex.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PMG/Statistic.pm

index c2b103fbdfdae70e57096cd845af55bf49e07b26..27b1166c62b427c2836b8f84e3745b2451e063bf 100755 (executable)
@@ -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};