From 61d325fa8ac6d088b31d2158e4ce1a74c88243e2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 Jun 2018 09:49:38 +0200 Subject: [PATCH] Use subquery filters for host groups if appropriate refs #2934 --- .../Backend/Ido/Query/HostgroupQuery.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupQuery.php index 84daa9fac..bbf8ed59c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupQuery.php @@ -18,6 +18,11 @@ class HostgroupQuery extends IdoQuery protected $groupOrigin = array('members'); + protected $subQueryTargets = array( + 'hostgroups' => 'hostgroup', + 'servicegroups' => 'servicegroup' + ); + protected $columnMap = array( 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', @@ -223,4 +228,23 @@ class HostgroupQuery extends IdoQuery array() ); } + + protected function joinSubQuery(IdoQuery $query, $name) + { + if ($name === 'hostgroup') { + $this->requireVirtualTable('members'); + + $query->joinVirtualTable('members'); + + return ['hgm.host_object_id', 'ho.object_id']; + } elseif ($name === 'servicegroup') { + $this->requireVirtualTable('members'); + + $query->joinVirtualTable('services'); + + return ['s.host_object_id', 'ho.object_id']; + } + + return parent::joinSubQuery($query, $name); + } }