Use subquery filters for services if appropriate

refs #2934

Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
Johannes Meyer 2018-06-20 14:56:09 +02:00 committed by Eric Lippmann
parent 824fa870a2
commit 186ef5a5a7
1 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class ServicestatusQuery extends IdoQuery
*/
protected $groupOrigin = array('hostgroups', 'servicegroups');
protected $subQueryTargets = array(
'hostgroups' => 'hostgroup',
'servicegroups' => 'servicegroup'
);
/**
* {@inheritdoc}
*/
@ -412,4 +417,19 @@ class ServicestatusQuery extends IdoQuery
parent::registerGroupColumns($alias, $table, $groupedColumns, $groupedTables);
}
}
protected function joinSubQuery(IdoQuery $query, $name)
{
if ($name === 'hostgroup') {
$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);
}
}