Use subquery filters for service notifications if appropriate

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

View File

@ -13,6 +13,11 @@ class ServicenotificationQuery extends IdoQuery
*/
protected $allowCustomVars = true;
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -233,4 +238,21 @@ class ServicenotificationQuery extends IdoQuery
return $group;
}
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);
}
}