From 29df41a3f55657d02d84afc3f1a507ff2f561d07 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 27 Sep 2010 15:13:43 +0200 Subject: [PATCH] fixed undefined index for sensor calculations --- backend/lib/Interpreter/SensorInterpreter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/lib/Interpreter/SensorInterpreter.php b/backend/lib/Interpreter/SensorInterpreter.php index b8c0d4c..928de2b 100644 --- a/backend/lib/Interpreter/SensorInterpreter.php +++ b/backend/lib/Interpreter/SensorInterpreter.php @@ -38,12 +38,12 @@ class SensorInterpreter extends Interpreter { public function getValues($groupBy = NULL) { $data = parent::getData($groupBy); - $values = array(); foreach ($data as $reading) { + $count = isset($reading[2]) ? $reading[2] : 1; $values[] = array( $reading[0], - $reading[1] / $reading[2], // calculate average (ungroup the sql sum() function) - $reading[2] + $reading[1] / $count, // calculate average (ungroup the sql sum() function) + $count ); }