From 1e393a1662d10d83a7aca2c556ef0aa7e50b6fd5 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 7 Oct 2011 14:26:01 +0200 Subject: new statistic, all_pools implemented --- application/models/EventreportMapper.php | 86 ++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 32 deletions(-) (limited to 'application/models/EventreportMapper.php') diff --git a/application/models/EventreportMapper.php b/application/models/EventreportMapper.php index 309dd18..7f7434e 100755 --- a/application/models/EventreportMapper.php +++ b/application/models/EventreportMapper.php @@ -167,51 +167,73 @@ class Application_Model_EventreportMapper public function getSuccessBarCount($poolID) { $db = Zend_Db_Table::getDefaultAdapter(); - $select = $this->getDbTable()->select() - ->setIntegrityCheck(false) - ->from(array('pcr' => 'poolctrl_eventreport'), - array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') - ) - ->join(array('pce' => 'poolctrl_event'), + if($poolID != 'all'){ + $select = $this->getDbTable()->select() + ->setIntegrityCheck(false) + ->from(array('pcr' => 'poolctrl_eventreport'), + array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') + ) + ->join(array('pce' => 'poolctrl_event'), + 'pce.eventID = pcr.eventID', + array()) + ->where('pce.pbs_poolID = ?', $poolID);} + else { + $select = $this->getDbTable()->select() + ->setIntegrityCheck(false) + ->from(array('pcr' => 'poolctrl_eventreport'), + array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') + ) + ->join(array('pce' => 'poolctrl_event'), 'pce.eventID = pcr.eventID', - array()) - ->where('pce.pbs_poolID = ?', $poolID); + array()); + } - $stmt = $db->query($select); - $result = $stmt->fetchAll(PDO::FETCH_NUM); + $stmt = $db->query($select); + $result = $stmt->fetchAll(PDO::FETCH_NUM); - foreach ($result as $r) { - $ret1 = array((int)$r[0],'Successful'); - $ret2 = array((int)$r[1],'Failed'); - $return[] = array($ret1,$ret2); - } + foreach ($result as $r) { + $ret1 = array((int)$r[0],'Successful'); + $ret2 = array((int)$r[1],'Failed'); + $return[] = array($ret1,$ret2); + } - return $return; + return $return; } public function getSuccessPieCount($poolID) { $db = Zend_Db_Table::getDefaultAdapter(); - $select = $this->getDbTable()->select() - ->setIntegrityCheck(false) - ->from(array('pcr' => 'poolctrl_eventreport'), - array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') - ) - ->join(array('pce' => 'poolctrl_event'), + if($poolID != 'all'){ + $select = $this->getDbTable()->select() + ->setIntegrityCheck(false) + ->from(array('pcr' => 'poolctrl_eventreport'), + array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') + ) + ->join(array('pce' => 'poolctrl_event'), + 'pce.eventID = pcr.eventID', + array()) + ->where('pce.pbs_poolID = ?', $poolID);} + else { + $select = $this->getDbTable()->select() + ->setIntegrityCheck(false) + ->from(array('pcr' => 'poolctrl_eventreport'), + array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))') + ) + ->join(array('pce' => 'poolctrl_event'), 'pce.eventID = pcr.eventID', - array()) - ->where('pce.pbs_poolID = ?', $poolID); + array()); + } - $stmt = $db->query($select); - $result = $stmt->fetchAll(PDO::FETCH_NUM); + $stmt = $db->query($select); + $result = $stmt->fetchAll(PDO::FETCH_NUM); - foreach ($result as $r) { - $ret1 = array('Successful', (int)$r[0]); - $ret2 = array('Failed', (int)$r[1]); - $return[] = array($ret1,$ret2); - } + foreach ($result as $r) { + $ret1 = array('Successful', (int)$r[0]); + $ret2 = array('Failed', (int)$r[1]); + $return[] = array($ret1,$ret2); + } - return $return; + return $return; } } -- cgit v1.2.3-55-g7522