Use subquery filters for host state history if appropriate

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

View File

@ -33,6 +33,11 @@ class HoststatehistoryQuery extends IdoQuery
'hard_state' => 1
);
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -186,4 +191,19 @@ class HoststatehistoryQuery extends IdoQuery
array()
);
}
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$query->joinVirtualTable('members');
return ['hgm.host_object_id', 'ho.object_id'];
} elseif ($name === 'servicegroup') {
$query->joinVirtualTable('services');
return ['s.host_object_id', 'ho.object_id'];
}
return parent::joinSubQuery($query, $name);
}
}