summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Wagner2011-11-16 16:09:02 +0100
committerSebastian Wagner2011-11-16 16:09:02 +0100
commite436fee45dee956d7cf5f0fbcf9758d6af57f00a (patch)
tree60f78e4b396ae512df83a66b956c3961a4be1067
parentmore clean up (diff)
downloadpoolctrl-e436fee45dee956d7cf5f0fbcf9758d6af57f00a.tar.gz
poolctrl-e436fee45dee956d7cf5f0fbcf9758d6af57f00a.tar.xz
poolctrl-e436fee45dee956d7cf5f0fbcf9758d6af57f00a.zip
more clean up
-rwxr-xr-xapplication/controllers/EventController.php1
-rwxr-xr-xapplication/controllers/StatisticsController.php24
-rwxr-xr-xapplication/models/EventMapper.php155
-rwxr-xr-xapplication/models/EventreportMapper.php50
-rwxr-xr-xapplication/views/scripts/statistics/category.phtml2
-rwxr-xr-xapplication/views/scripts/statistics/running.phtml2
-rwxr-xr-xapplication/views/scripts/statistics/success.phtml2
-rwxr-xr-xapplication/views/scripts/statistics/type.phtml2
8 files changed, 55 insertions, 183 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index ab6f913..8cd21ea 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -1346,7 +1346,6 @@ class EventController extends Zend_Controller_Action
'running' => $event->getRunning(),
)
);
- //}
}
echo json_encode($events);
}
diff --git a/application/controllers/StatisticsController.php b/application/controllers/StatisticsController.php
index 868a2a6..b98acf4 100755
--- a/application/controllers/StatisticsController.php
+++ b/application/controllers/StatisticsController.php
@@ -41,7 +41,7 @@ class StatisticsController extends Zend_Controller_Action
}
}
- public function categorylistAction() {
+ public function categoryplotAction() {
if(!$this->acl->checkRight('eo')) {
$this->_redirect('/');
}
@@ -57,15 +57,15 @@ class StatisticsController extends Zend_Controller_Action
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
}
- $ret['dataBar'] = $this->eventMapper->getCategoryBarCount($poolID);
- $ret['dataPie'] = $this->eventMapper->getCategoryPieCount($poolID);
+ $ret['dataBar'] = $this->eventMapper->getCategoryPlotdata($poolID, 1);
+ $ret['dataPie'] = $this->eventMapper->getCategoryPlotdata($poolID, 2);
$ret['color'] = $this->eventcategoryMapper->getCategoryColor($poolID, null);
echo json_encode($ret);
}
- public function runninglistAction() {
+ public function runningplotAction() {
if(!$this->acl->checkRight('er')) {
$this->_redirect('/');
}
@@ -81,14 +81,14 @@ class StatisticsController extends Zend_Controller_Action
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
}
- $ret['dataBar'] = $this->eventMapper->getRunningBarCount($poolID);
- $ret['dataPie'] = $this->eventMapper->getRunningPieCount($poolID);
+ $ret['dataBar'] = $this->eventMapper->getRunningPlotdata($poolID, 1);
+ $ret['dataPie'] = $this->eventMapper->getRunningPlotdata($poolID, 2);
echo json_encode($ret);
}
- public function successlistAction() {
+ public function successplotAction() {
if(!$this->acl->checkRight('er')) {
$this->_redirect('/');
}
@@ -104,14 +104,14 @@ class StatisticsController extends Zend_Controller_Action
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
}
- $ret['dataBar'] = $this->eventreportMapper->getSuccessBarCount($poolID);
- $ret['dataPieS'] = $this->eventreportMapper->getSuccessPieCount($poolID);
+ $ret['dataBar'] = $this->eventreportMapper->getSuccessPlotdata($poolID, 1);
+ $ret['dataPieS'] = $this->eventreportMapper->getSuccessPlotdata($poolID, 2);
echo json_encode($ret);
}
- public function typelistAction() {
+ public function typeplotAction() {
if(!$this->acl->checkRight('eo')) {
$this->_redirect('/');
}
@@ -127,8 +127,8 @@ class StatisticsController extends Zend_Controller_Action
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
}
- $ret['dataBar'] = $this->eventMapper->getTypeBarCount($poolID);
- $ret['dataPie'] = $this->eventMapper->getTypePieCount($poolID);
+ $ret['dataBar'] = $this->eventMapper->getTypePlotdata($poolID, 1);
+ $ret['dataPie'] = $this->eventMapper->getTypePlotdata($poolID, 2);
echo json_encode($ret);
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 438613f..01d2f4c 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -186,44 +186,7 @@ class Application_Model_EventMapper
return array_diff_assoc($vv1,$vv2);
}
- public function getCategoryBarCount($poolID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- if($poolID != 'all'){
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array())
- ->where('pce.pbs_poolID = ?', $poolID)
- ->group('pce.category')
- ->order('pce.category ASC');}
- else {
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array())
- ->group('pce.category')
- ->order('pce.category ASC');
- }
-
- $stmt = $db->query($select);
- $result = $stmt->fetchAll(PDO::FETCH_NUM);
- $ret = null;
-
- foreach ($result as $r) {
- $ret[] = array((int)$r[0], $r[1]);
- }
-
- return array($ret);
- }
-
- public function getCategoryPieCount($poolID) {
+ public function getCategoryPlotdata($poolID, $plotType) {
$db = Zend_Db_Table::getDefaultAdapter();
if($poolID != 'all'){
@@ -254,13 +217,17 @@ class Application_Model_EventMapper
$ret = null;
foreach ($result as $r) {
- $ret[] = array($r[0], (int)$r[1]);
+ if($plotType == 1) {
+ $ret[] = array((int)$r[1], $r[0]);
+ } else if ($plotType == 2) {
+ $ret[] = array($r[0], (int)$r[1]);
+ }
}
return array($ret);
}
- public function getRunningBarCount($poolID) {
+ public function getRunningPlotdata($poolID, $plotType) {
$db = Zend_Db_Table::getDefaultAdapter();
if($poolID != 'all'){
@@ -288,51 +255,21 @@ class Application_Model_EventMapper
$result = $stmt->fetchAll(PDO::FETCH_NUM);
foreach ($result as $r) {
- $ret1 = array((int)$r[0],'not over');
- $ret2 = array((int)$r[1],'over');
- $return[] = array($ret1,$ret2);
- }
-
- return $return;
- }
-
- public function getRunningPieCount($poolID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- if($poolID != 'all'){
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('count1' => 'SUM(IF(pce.running=1,1,0))', 'count0' => 'SUM(IF(pce.running=1,0,1))')
- )
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array())
- ->where('pce.pbs_poolID = ?', $poolID);}
- else {
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('over' => 'SUM(IF(pce.running=1,1,0))', 'not_over' => 'SUM(IF(pce.running=1,0,1))')
- )
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array());
- }
-
- $stmt = $db->query($select);
- $result = $stmt->fetchAll(PDO::FETCH_NUM);
-
- foreach ($result as $r) {
- $ret1 = array('over', (int)$r[0]);
- $ret2 = array('not over', (int)$r[1]);
- $return[] = array($ret1,$ret2);
+ if($plotType == 1) {
+ $ret1 = array((int)$r[0],'not over');
+ $ret2 = array((int)$r[1],'over');
+ $return[] = array($ret1,$ret2);
+ } else if($plotType == 2) {
+ $ret1 = array('over', (int)$r[0]);
+ $ret2 = array('not over', (int)$r[1]);
+ $return[] = array($ret1,$ret2);
+ }
}
return $return;
}
- public function getTypeBarCount($poolID) {
+ public function getTypePlotdata($poolID, $plotType) {
$db = Zend_Db_Table::getDefaultAdapter();
if($poolID != 'all'){
@@ -364,51 +301,17 @@ class Application_Model_EventMapper
$result = $stmt->fetchAll(PDO::FETCH_NUM);
foreach ($result as $r) {
- $ret1 = array((int)$r[0], 'other');
- $ret2 = array((int)$r[1], 'repeat');
- $ret3 = array((int)$r[2], 'immediate');
- $return[] = array($ret1,$ret2,$ret3);
- }
-
- return $return;
- }
-
- public function getTypePieCount($poolID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- if($poolID != 'all'){
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('other' => 'SUM(IF(pce.repeat=0 AND pce.immediate=0,1,0))',
- 'repeat' => 'SUM(IF(pce.repeat=1 AND pce.immediate=0,1,0))',
- 'immediate' => 'SUM(IF(pce.repeat=0 AND pce.immediate=1,1,0))')
- )
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array())
- ->where('pce.pbs_poolID = ?', $poolID);}
- else {
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('other' => 'SUM(IF(pce.repeat=0 AND pce.immediate=0,1,0))',
- 'repeat' => 'SUM(IF(pce.repeat=1 AND pce.immediate=0,1,0))',
- 'immediate' => 'SUM(IF(pce.repeat=0 AND pce.immediate=1,1,0))')
- )
- ->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID',
- array());
- }
-
- $stmt = $db->query($select);
- $result = $stmt->fetchAll(PDO::FETCH_NUM);
-
- foreach ($result as $r) {
- $ret1 = array('other', (int)$r[0]);
- $ret2 = array('repeat', (int)$r[1]);
- $ret3 = array('immediate', (int)$r[2]);
- $return[] = array($ret1,$ret2,$ret3);
+ if($plotType == 1) {
+ $ret1 = array((int)$r[0], 'other');
+ $ret2 = array((int)$r[1], 'repeat');
+ $ret3 = array((int)$r[2], 'immediate');
+ $return[] = array($ret1,$ret2,$ret3);
+ } else if ($plotType == 2) {
+ $ret1 = array('other', (int)$r[0]);
+ $ret2 = array('repeat', (int)$r[1]);
+ $ret3 = array('immediate', (int)$r[2]);
+ $return[] = array($ret1,$ret2,$ret3);
+ }
}
return $return;
@@ -468,7 +371,7 @@ class Application_Model_EventMapper
$event->setID($result['eventID']);
$return[] = $event;
}
-
+
return $return;
}
diff --git a/application/models/EventreportMapper.php b/application/models/EventreportMapper.php
index da37e66..371fa26 100755
--- a/application/models/EventreportMapper.php
+++ b/application/models/EventreportMapper.php
@@ -164,7 +164,7 @@ class Application_Model_EventreportMapper
return array_diff_assoc($vv1,$vv2);
}
- public function getSuccessBarCount($poolID) {
+ public function getSuccessPlotdata($poolID, $plotType) {
$db = Zend_Db_Table::getDefaultAdapter();
if($poolID != 'all'){
@@ -192,49 +192,19 @@ class Application_Model_EventreportMapper
$result = $stmt->fetchAll(PDO::FETCH_NUM);
foreach ($result as $r) {
- $ret1 = array((int)$r[0],'Succeeded');
- $ret2 = array((int)$r[1],'Failed');
- $return[] = array($ret1,$ret2);
+ if($plotType == 1) {
+ $ret1 = array((int)$r[0],'Succeeded');
+ $ret2 = array((int)$r[1],'Failed');
+ $return[] = array($ret1,$ret2);
+ } else if($plotType == 2) {
+ $ret1 = array('Successful', (int)$r[0]);
+ $ret2 = array('Failed', (int)$r[1]);
+ $return[] = array($ret1,$ret2);
+ }
}
return $return;
}
- public function getSuccessPieCount($poolID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- if($poolID != 'all'){
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pcr' => 'poolctrl_eventreport'),
- array('count1' => 'SUM(IF(pcr.result="succeeded",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="succeeded",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))')
- )
- ->join(array('pce' => 'poolctrl_event'),
- 'pce.eventID = pcr.eventID',
- array());
- }
-
- $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);
- }
-
- return $return;
- }
-
}
diff --git a/application/views/scripts/statistics/category.phtml b/application/views/scripts/statistics/category.phtml
index 8319d20..db17b63 100755
--- a/application/views/scripts/statistics/category.phtml
+++ b/application/views/scripts/statistics/category.phtml
@@ -25,7 +25,7 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
- $.get("/statistics/categorylist/poolID/" + poolID, function(data) {
+ $.get("/statistics/categoryplot/poolID/" + poolID, function(data) {
if(data.dataBar == '' && poolID != 'default') {
$( "#noEventsDialog" ).dialog('open');
$('#plotBar').empty();
diff --git a/application/views/scripts/statistics/running.phtml b/application/views/scripts/statistics/running.phtml
index 7bf27b8..a23628c 100755
--- a/application/views/scripts/statistics/running.phtml
+++ b/application/views/scripts/statistics/running.phtml
@@ -25,7 +25,7 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
- $.get("/statistics/runninglist/poolID/" + poolID, function(data) {
+ $.get("/statistics/runningplot/poolID/" + poolID, function(data) {
if(data.dataBar == '0,Event over,0,Event not over' && poolID != 'default') {
$('#plotBar').empty();
$('#plotPie').empty();
diff --git a/application/views/scripts/statistics/success.phtml b/application/views/scripts/statistics/success.phtml
index e00a01d..5d5c895 100755
--- a/application/views/scripts/statistics/success.phtml
+++ b/application/views/scripts/statistics/success.phtml
@@ -24,7 +24,7 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
- $.get("/statistics/successlist/poolID/" + poolID, function(data) {
+ $.get("/statistics/successplot/poolID/" + poolID, function(data) {
if(data.dataBar == '0,Successful,0,Failed' && poolID != 'default') {
$( "#noEventsDialog" ).dialog('open');
$('#plotBar').empty();
diff --git a/application/views/scripts/statistics/type.phtml b/application/views/scripts/statistics/type.phtml
index a34eb2b..6872436 100755
--- a/application/views/scripts/statistics/type.phtml
+++ b/application/views/scripts/statistics/type.phtml
@@ -25,7 +25,7 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
- $.get("/statistics/typelist/poolID/" + poolID, function(data) {
+ $.get("/statistics/typeplot/poolID/" + poolID, function(data) {
if(data.dataBar == '0,other,0,repeat,0,immediate' && poolID != 'default') {
$('#plotBar').empty();
$('#plotPie').empty();