summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/StatisticController.php46
-rwxr-xr-xapplication/models/EventMapper.php29
-rwxr-xr-xapplication/models/EventcategoryMapper.php31
-rw-r--r--application/views/scripts/statistic/index.phtml2
4 files changed, 51 insertions, 57 deletions
diff --git a/application/controllers/StatisticController.php b/application/controllers/StatisticController.php
index 4def963..7af5dc0 100644
--- a/application/controllers/StatisticController.php
+++ b/application/controllers/StatisticController.php
@@ -5,11 +5,13 @@ class StatisticController extends Zend_Controller_Action
protected $config;
protected $pbs2host;
protected $eventMapper;
+ protected $eventcategoryMapper;
public function init()
{
$this->eventMapper = new Application_Model_EventMapper();
+ $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
if (Zend_Auth::getInstance()->hasIdentity()) {
$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
@@ -37,13 +39,13 @@ class StatisticController extends Zend_Controller_Action
$this->view->right = $this->acl->checkRight($rightShortcut);
}
- public function dumpAction() {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
- $data = $this->_request->getParam("data");
- var_dump($data);
- }
-
+ public function dumpAction() {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $data = $this->_request->getParam("data");
+ var_dump($data);
+ }
+
public function categorylistAction() {
$this->_helper->layout->disableLayout();
@@ -52,30 +54,24 @@ class StatisticController extends Zend_Controller_Action
$userIDsSession = new Zend_Session_Namespace('userIDs');
$userIDsSession->poolID = $poolID;
- if($this->acl->checkRight('eoo')) {
+ /*if($this->acl->checkRight('eoo')) {
$eventList = $this->eventMapper->fetchAll();
} else {
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
- }
-
- $count = 0;
-
- foreach ($eventList as $event){
+ }*/
- if($event->getPbs_poolID() == $poolID AND $event->getCategory() == $category) {
- $count += 1;
- }
- }
//echo $count;
+ $ret2 = $this->eventMapper->getCategoryCount();
+
$ret = array();
-
- $ret[] = array(3,'Lecture');
- $ret[] = array(2,'Boot');
- $ret[] = array(65,'Shutdown');
- $ret[] = array(20,'Maintenance');
-
- echo json_encode(array($ret));
-
+
+ $ret[] = array(3,'Lecture');
+ $ret[] = array(2,'Boot');
+ $ret[] = array(65,'Shutdown');
+ $ret[] = array(20,'Maintenance');
+
+ echo json_encode($ret2);
+
}
} \ No newline at end of file
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index cacff29..71d472d 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -183,4 +183,33 @@ class Application_Model_EventMapper
$vv2 = $v2->toArray();
return array_diff($vv1,$vv2);
}
+
+ public function getCategoryCount() {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable,
+ array('count' => 'COUNT(*)', 'category'))
+ ->group('category');
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll();
+
+ return array($result);
+ }
+
+ /* Erzeugt diese Anfrage:
+ // SELECT p."product_id", COUNT(*) AS line_items_per_product
+ // FROM "products" AS p JOIN "line_items" AS l
+ // ON p.product_id = l.product_id
+ // GROUP BY p.product_id
+ *
+ *
+ *
+ *
+ * SELECT category, COUNT( * ) AS count
+ * FROM `poolctrl_event`
+ * GROUP BY category
+ * LIMIT 0 , 30
+ */
+
} \ No newline at end of file
diff --git a/application/models/EventcategoryMapper.php b/application/models/EventcategoryMapper.php
index 1ba0369..b70a116 100755
--- a/application/models/EventcategoryMapper.php
+++ b/application/models/EventcategoryMapper.php
@@ -82,37 +82,6 @@ class Application_Model_EventcategoryMapper
return $this->_dbTable;
}
-
- /*public function getCategoryCount() {
-
-
- $select = $db->select()
- ->from(array('p' => 'products'),
- array('product_id'))
- ->join(array('l' => 'line_items'),
- 'p.product_id = l.product_id',
- array('line_items_per_product' => 'COUNT(*)'))
- ->group('p.product_id');
-
-
-// Erzeugt diese Anfrage:
-// SELECT p."product_id", COUNT(*) AS line_items_per_product
-// FROM "products" AS p JOIN "line_items" AS l
-// ON p.product_id = l.product_id
-// GROUP BY p.product_id
- *
- *
- *
- *
- * SELECT category, COUNT( * ) AS count
- * FROM `poolctrl_event`
- * GROUP BY category
- * LIMIT 0 , 30
-
-
- }*/
-
-
public function save(Application_Model_Eventcategory $eventcategory)
{
diff --git a/application/views/scripts/statistic/index.phtml b/application/views/scripts/statistic/index.phtml
index d6c9ca9..8f63416 100644
--- a/application/views/scripts/statistic/index.phtml
+++ b/application/views/scripts/statistic/index.phtml
@@ -30,7 +30,7 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
- $.get("/statistic/categorylist/poolID/" + poolID + "/category/" + 2, function(data) {
+ $.get("/statistic/categorylist/poolID/" + poolID, function(data) {
// lecture = data.lecture;
// boot = data.boot;
// shutdown = data.shutdown;