Skip to content

Commit

Permalink
StatusSummaryQuery: reorganize, add new columns
Browse files Browse the repository at this point in the history
refs #6993
  • Loading branch information
Thomas-Gelf committed Sep 5, 2014
1 parent 949ea1c commit 38c6d6a
Showing 1 changed file with 24 additions and 2 deletions.
Expand Up @@ -8,7 +8,15 @@

class StatusSummaryQuery extends IdoQuery
{
protected $subHosts;

protected $subServices;

protected $columnMap = array(
'services' => array(
'service_host_name' => 'so.name1',
'service_description' => 'so.name2',
),
'hoststatussummary' => array(
'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)',
'hosts_up_not_checked' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 AND is_active_checked = 0 AND is_passive_checked = 0 THEN 1 ELSE 0 END)',
Expand Down Expand Up @@ -159,10 +167,24 @@ protected function joinBaseTables()
'object_type' => '(\'service\')'
));
$union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL);
$this->subHosts = $hosts;
$this->subServices = $services;
$this->select->from(array('statussummary' => $union), array());
$this->joinedVirtualTables = array(
'servicestatussummary' => true,
'hoststatussummary' => true
'services' => true,
'servicestatussummary' => true,
'hoststatussummary' => true
);
}

public function whereToSql($col, $sign, $expression)
{
if ($col === 'so.name1') {
$this->subServices->where('so.name1 ' . $sign . ' ?', $expression);
return '';
return 'sh.state_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression));
} else {
return parent::whereToSql($col, $sign, $expression);
}
}
}

0 comments on commit 38c6d6a

Please sign in to comment.