Use subquery filters for service downtime history if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-22 09:30:16 +02:00
parent 0ca97d191f
commit df7b5d663a
1 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class ServicedowntimestarthistoryQuery extends IdoQuery
*/
protected $groupOrigin = array('hostgroups', 'servicegroups');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -178,4 +183,19 @@ class ServicedowntimestarthistoryQuery extends IdoQuery
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);
}
}