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
1 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class ServicedowntimeQuery extends IdoQuery
*/
protected $groupOrigin = array('hostgroups', 'servicegroups');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -199,4 +204,19 @@ class ServicedowntimeQuery extends IdoQuery
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);
}
}