Use subquery filters for service flapping history if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-22 09:35:56 +02:00
parent c4de14eb05
commit a3ec0df7c5

View File

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