Use subquery filters for contact groups if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-20 15:12:22 +02:00
parent f7f02bdc8f
commit 271a1d72f1
1 changed files with 24 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class ContactgroupQuery extends IdoQuery
*/ */
protected $groupOrigin = array('hosts', 'members', 'services'); protected $groupOrigin = array('hosts', 'members', 'services');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -187,4 +192,23 @@ class ContactgroupQuery extends IdoQuery
array() array()
); );
} }
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$this->requireVirtualTable('hosts');
$query->joinVirtualTable('members');
return ['hgm.host_object_id', 'ho.object_id'];
} elseif ($name === 'servicegroup') {
$this->requireVirtualTable('services');
$query->joinVirtualTable('members');
return ['sgm.service_object_id', 'so.object_id'];
}
return parent::joinSubQuery($query, $name);
}
} }