/** * Return any other values from the same submission as the given scalar. * * @param Tracker_ScalarDao $scalarDao scalar DAO * @return array associative array with keys equal to the metric names */ public function getOtherValuesFromSubmission($scalarDao) { $sql = $this->database->select()->setIntegrityCheck(false)->from(array('s' => 'tracker_scalar'))->join(array('t' => 'tracker_trend'), 's.trend_id = t.trend_id')->where('s.submit_time = ?', $scalarDao->getSubmitTime())->where('s.user_id = ?', $scalarDao->getUserId())->where('t.producer_id = ?', $scalarDao->getTrend()->getProducerId())->order('metric_name ASC'); $rows = $this->database->fetchAll($sql); $scalarDaos = array(); /** @var Zend_Db_Table_Row_Abstract $row */ foreach ($rows as $row) { $scalarDaos[$row['metric_name']] = array('value' => number_format((double) $row['value'], 4, '.', ''), 'unit' => $row['unit']); } return $scalarDaos; }
/** * Return the threshold notifications whose conditions are met by the given scalar. * * @param Tracker_ScalarDao $scalarDao scalar DAO * @return array threshold notification DAOs */ public function getNotifications($scalarDao) { $sql = $this->database->select()->setIntegrityCheck(false)->where('trend_id = ?', $scalarDao->getTrend()->getKey()); $rows = $this->database->fetchAll($sql); $thresholdNotificationDaos = array(); /** @var Zend_Db_Table_Row_Abstract $row */ foreach ($rows as $row) { /** @var Tracker_ThresholdNotificationDao $thresholdNotificationDao */ $thresholdNotificationDao = $this->initDao('ThresholdNotification', $row, $this->moduleName); if ($this->testThreshold($scalarDao->getValue(), $thresholdNotificationDao)) { $thresholdNotificationDaos[] = $thresholdNotificationDao; } } return $thresholdNotificationDaos; }