Use subquery filters for host groups if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-22 09:49:38 +02:00
parent a3ec0df7c5
commit 61d325fa8a
1 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,11 @@ class HostgroupQuery extends IdoQuery
protected $groupOrigin = array('members');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
protected $columnMap = array(
'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
@ -223,4 +228,23 @@ class HostgroupQuery extends IdoQuery
array()
);
}
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$this->requireVirtualTable('members');
$query->joinVirtualTable('members');
return ['hgm.host_object_id', 'ho.object_id'];
} elseif ($name === 'servicegroup') {
$this->requireVirtualTable('members');
$query->joinVirtualTable('services');
return ['s.host_object_id', 'ho.object_id'];
}
return parent::joinSubQuery($query, $name);
}
}