Use subquery filters for service groups if appropriate

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

View File

@ -14,6 +14,11 @@ class ServicegroupQuery extends IdoQuery
protected $allowCustomVars = true; protected $allowCustomVars = true;
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
protected $columnMap = array( protected $columnMap = array(
'hostgroups' => array( 'hostgroups' => array(
'hostgroup_name' => 'hgo.name1' 'hostgroup_name' => 'hgo.name1'
@ -178,4 +183,21 @@ class ServicegroupQuery extends IdoQuery
array() array()
); );
} }
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$this->requireVirtualTable('members');
$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);
}
} }