Use subquery filters for service downtimes if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-20 15:09:46 +02:00
parent 9f7b9edffe
commit f7f02bdc8f

View File

@ -23,6 +23,11 @@ class ServicedowntimeQuery extends IdoQuery
*/ */
protected $groupOrigin = array('hostgroups', 'servicegroups'); protected $groupOrigin = array('hostgroups', 'servicegroups');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -199,4 +204,19 @@ class ServicedowntimeQuery extends IdoQuery
array() array()
); );
} }
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$query->joinVirtualTable('services');
return ['so.object_id', 'so.object_id'];
} elseif ($name === 'servicegroup') {
$query->joinVirtualTable('members');
return ['sgm.service_object_id', 'so.object_id'];
}
return parent::joinSubQuery($query, $name);
}
} }