From 0ca97d191f60a4c0d1b92731bfa531f68fc98452 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 Jun 2018 09:29:55 +0200 Subject: [PATCH] Use subquery filters for host downtime history if appropriate refs #2934 --- .../Query/HostdowntimestarthistoryQuery.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php index f3c989bfc..003cc9e88 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php @@ -23,6 +23,11 @@ class HostdowntimestarthistoryQuery extends IdoQuery */ protected $groupOrigin = array('hostgroups', 'services'); + protected $subQueryTargets = array( + 'hostgroups' => 'hostgroup', + 'servicegroups' => 'servicegroup' + ); + /** * {@inheritdoc} */ @@ -180,4 +185,19 @@ class HostdowntimestarthistoryQuery 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); + } }