From bdb73ec06ecce701b3631ed5c757cc7f576498b7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 Jun 2018 09:25:07 +0200 Subject: [PATCH] Use subquery filters for host state history if appropriate refs #2934 --- .../Ido/Query/HoststatehistoryQuery.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php index baad6e1ef..a60c75485 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php @@ -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); + } }