Use subquery filters for service state history if appropriate

refs #2934
This commit is contained in:
Eric Lippmann 2018-06-22 09:25:36 +02:00
parent bdb73ec06e
commit 81b6b0129b
1 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,11 @@ class ServicestatehistoryQuery extends IdoQuery
'hard_state' => 1
);
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -184,4 +189,19 @@ class ServicestatehistoryQuery 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);
}
}