diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index 345b446385b102d33e90d701c2bd0ef2eab8b5b0..9be2b4e2d441ecd574f9479394754e0db282d011 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -113,17 +113,34 @@ class sspmod_statistics_Aggregator { foreach ($ruleresults AS $fileno => $fileres) { $slotlist = array_keys($fileres); + + $maxslot = $slotlist[count($slotlist)-1]; + #print_r($slotlist); // Get start and end slot number within the file, based on the fileslot. - $start = $datehandler->toSlot($datehandler->fromSlot($fileno, $this->statrules[$rulename]['fileslot']), $this->statrules[$rulename]['slot']); - $end = $datehandler->toSlot($datehandler->fromSlot($fileno+1, $this->statrules[$rulename]['fileslot']), $this->statrules[$rulename]['slot']); + $start = (int)$datehandler->toSlot($datehandler->fromSlot($fileno, $this->statrules[$rulename]['fileslot']), $this->statrules[$rulename]['slot']); + $end = (int)$datehandler->toSlot($datehandler->fromSlot($fileno+1, $this->statrules[$rulename]['fileslot']), $this->statrules[$rulename]['slot']); // Fill in missing entries and sort file results $filledresult = array(); for ($slot = $start; $slot < $end; $slot++) { - $filledresult[$slot] = (isset($fileres[$slot])) ? $fileres[$slot] : array('_' => 0); + #print_r(gettype($slot)); + if (array_key_exists($slot, $fileres)) { + $filledresult[$slot] = $fileres[$slot]; + } else { + #echo('SLot [' . $slot . '] of [' . $maxslot . ']' . "\n"); + if ($slot > $maxslot) { + $filledresult[$slot] = array('_' => -1); + } else { + $filledresult[$slot] = array('_' => NULL); + } + } + #print_r($filledresult[$slot]); +# = (isset($fileres[$slot])) ? $fileres[$slot] : array('_' => NULL); } + #print_r($filledresult); exit; + // store file file_put_contents($this->statdir . '/' . $rulename . '-' . $fileno . '.stat', serialize($filledresult), LOCK_EX ); } diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php index 2f89002677e118da519bf60c9b7fe0fff89c6f2f..43ee123ae1841726612012a0784bdd7abd651560 100644 --- a/modules/statistics/www/showstats.php +++ b/modules/statistics/www/showstats.php @@ -156,6 +156,10 @@ $maxvaluetime = 0; $debugdata = array(); + +/* + * Search for maximum value in order to scale the Y-scale of the graph presentation. + */ $maxdelimiter = $delimiter; if (array_key_exists('graph.total', $statrules[$rule]) && $statrules[$rule]['graph.total'] === TRUE) { $maxdelimiter = '_'; @@ -223,7 +227,11 @@ function getPercentValues($results, $delimiter) { foreach($results AS $slot => $res) { #echo ('<p>new value: ' . number_format(100*$res[$delimiter] / $max, 2)); if (array_key_exists($delimiter, $res)) { - $dataset[] = number_format(100*$res[$delimiter] / $max, 2); + if ($res[$delimiter] === -1) { + $dataset[] = -1; + } else { + $dataset[] = number_format(100*$res[$delimiter] / $max, 2); + } } else { $dataset[] = '0'; } @@ -252,6 +260,8 @@ if ($delimiter !== '_') { } } +#echo('<pre>'); print_r($datasets); exit; + #echo 'set axis on lastslot [' . $lastslot . ']'; $axis[] = $datehandler->prettyDateSlot($lastslot+1, $slotsize, $dateformat_intra); #print_r($axis);