diff options
author | Simon Rettberg | 2017-04-03 13:51:34 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-04-03 13:51:34 +0200 |
commit | 3cd3abab1a33459d3613fa342cbd8fd9135b1202 (patch) | |
tree | 676bdecc56c4d65d1d7e1db433783c98617b0d2c /modules-available/statistics_reporting | |
parent | [statistics_reporting] Don't return so many NULL fields from queries (diff) | |
download | slx-admin-3cd3abab1a33459d3613fa342cbd8fd9135b1202.tar.gz slx-admin-3cd3abab1a33459d3613fa342cbd8fd9135b1202.tar.xz slx-admin-3cd3abab1a33459d3613fa342cbd8fd9135b1202.zip |
[statistics_reporting] Convert NULL to 0 so stupidtable doesn't mess up
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r-- | modules-available/statistics_reporting/inc/getdata.inc.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules-available/statistics_reporting/inc/getdata.inc.php b/modules-available/statistics_reporting/inc/getdata.inc.php index f65ee868..a167c2e5 100644 --- a/modules-available/statistics_reporting/inc/getdata.inc.php +++ b/modules-available/statistics_reporting/inc/getdata.inc.php @@ -40,6 +40,7 @@ class GetData $res = Queries::getLocationStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound); $data = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $median = self::calcMedian(self::calcMedian($row['medianSessionLength'])); $entry = array( 'location' => ($anonymize ? $row['locHash'] : $row['locName']), @@ -69,6 +70,7 @@ class GetData $res = Queries::getClientStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound); $data = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $median = self::calcMedian(self::calcMedian($row['medianSessionLength'])); $entry = array( 'hostname' => ($anonymize ? $row['clientHash'] : $row['clientName']), @@ -116,12 +118,20 @@ class GetData $data = array(); $vm = $anonymize ? 'vmHash' : 'name'; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $data[] = array('vm' => $row[$vm], 'sessions' => $row['count']); } return $data; } - + private function nullToZero(&$row) + { + foreach ($row as &$field) { + if (is_null($field)) { + $field = 0; + } + } + } // Format $seconds into ".d .h .m .s" format (day, hour, minute, second) private static function formatSeconds($seconds) |