Use subquery filters for service comments if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-20 15:27:59 +02:00
parent a84cc40aa8
commit 84c6055a17
1 changed files with 22 additions and 0 deletions

View File

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