Use subquery filters for service comment history if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-22 09:32:35 +02:00
parent 2ee0f99ed1
commit 1d4ee7824a
1 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class ServicecommenthistoryQuery extends IdoQuery
*/ */
protected $groupOrigin = array('hostgroups', 'servicegroups', 'services'); protected $groupOrigin = array('hostgroups', 'servicegroups', 'services');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -169,4 +174,19 @@ class ServicecommenthistoryQuery extends IdoQuery
array() array()
); );
} }
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$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);
}
} }