Use subquery filters for host downtimes if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-20 15:09:15 +02:00
parent 186ef5a5a7
commit 9f7b9edffe
1 changed files with 20 additions and 0 deletions

View File

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