mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
c69a46d005
commit
ea32d3dfb3
@ -6,10 +6,23 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
|||||||
use Zend_Db_Select;
|
use Zend_Db_Select;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query for event history
|
||||||
|
*/
|
||||||
class EventHistoryQuery extends IdoQuery
|
class EventHistoryQuery extends IdoQuery
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Subqueries used for the event history query
|
||||||
|
*
|
||||||
|
* @type IdoQuery[]
|
||||||
|
*
|
||||||
|
* @see EventHistoryQuery::joinBaseTables() For the used subqueries.
|
||||||
|
*/
|
||||||
protected $subQueries = array();
|
protected $subQueries = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected $columnMap = array(
|
protected $columnMap = array(
|
||||||
'eventhistory' => array(
|
'eventhistory' => array(
|
||||||
'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)",
|
'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)",
|
||||||
@ -41,8 +54,14 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected $useSubqueryCount = true;
|
protected $useSubqueryCount = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function joinBaseTables()
|
protected function joinBaseTables()
|
||||||
{
|
{
|
||||||
$columns = array(
|
$columns = array(
|
||||||
@ -77,15 +96,20 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
$this->joinedVirtualTables = array('eventhistory' => true);
|
$this->joinedVirtualTables = array('eventhistory' => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function order($columnOrAlias, $dir = null)
|
public function order($columnOrAlias, $dir = null)
|
||||||
{
|
{
|
||||||
foreach ($this->subQueries as $sub) {
|
foreach ($this->subQueries as $sub) {
|
||||||
$sub->requireColumn($columnOrAlias);
|
$sub->requireColumn($columnOrAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::order($columnOrAlias, $dir);
|
return parent::order($columnOrAlias, $dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function addFilter(Filter $filter)
|
public function addFilter(Filter $filter)
|
||||||
{
|
{
|
||||||
foreach ($this->subQueries as $sub) {
|
foreach ($this->subQueries as $sub) {
|
||||||
@ -94,6 +118,9 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function where($condition, $value = null)
|
public function where($condition, $value = null)
|
||||||
{
|
{
|
||||||
$this->requireColumn($condition);
|
$this->requireColumn($condition);
|
||||||
@ -103,6 +130,11 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join host groups
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
protected function joinHostgroups()
|
protected function joinHostgroups()
|
||||||
{
|
{
|
||||||
$this->select->join(
|
$this->select->join(
|
||||||
@ -121,6 +153,11 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join hosts
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
protected function joinHosts()
|
protected function joinHosts()
|
||||||
{
|
{
|
||||||
$this->select->joinLeft(
|
$this->select->joinLeft(
|
||||||
@ -131,6 +168,11 @@ class EventHistoryQuery extends IdoQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join services
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
protected function joinServices()
|
protected function joinServices()
|
||||||
{
|
{
|
||||||
$this->select->joinLeft(
|
$this->select->joinLeft(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user