Use subquery filters for hosts if appropriate
refs #2934 (EL): Alternative service group subquery filter: ```php $this->joinVirtualTable('services'); $query->joinVirtualTable('members'); return ['sgm.service_object_id', 'so.object_id']; ``` But I think the committed solution is better. Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
parent
4b80b3e7ee
commit
824fa870a2
|
@ -20,6 +20,11 @@ class HoststatusQuery extends IdoQuery
|
|||
*/
|
||||
protected $groupOrigin = array('hostgroups', 'servicegroups', 'services');
|
||||
|
||||
protected $subQueryTargets = array(
|
||||
'hostgroups' => 'hostgroup',
|
||||
'servicegroups' => 'servicegroup'
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -291,4 +296,19 @@ class HoststatusQuery extends IdoQuery
|
|||
'unhandled_service_count'
|
||||
));
|
||||
}
|
||||
|
||||
protected function joinSubQuery(IdoQuery $query, $name)
|
||||
{
|
||||
if ($name === 'hostgroup') {
|
||||
$query->joinVirtualTable('members');
|
||||
|
||||
return ['hgm.host_object_id', 'ho.object_id'];
|
||||
} elseif ($name === 'servicegroup') {
|
||||
$query->joinVirtualTable('services');
|
||||
|
||||
return ['s.host_object_id', 'ho.object_id'];
|
||||
}
|
||||
|
||||
return parent::joinSubQuery($query, $name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue