From 068c0b6ed269481038edc194f62b4031205ec6da Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 18 Jun 2015 10:38:15 +0200 Subject: [PATCH] ServicedowntimeQuery: PostgreSQL grouping... refs #9009 --- .../Ido/Query/ServicedowntimeQuery.php | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php index 970d48728..09162ea35 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php @@ -99,7 +99,6 @@ class ServicedowntimeQuery extends IdoQuery 'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3', array() ); - $this->group(array('sd.scheduleddowntime_id', 'so.name2', 'so.name1')); } /** @@ -146,7 +145,6 @@ class ServicedowntimeQuery extends IdoQuery 'sgo.object_id = sg.servicegroup_object_id AND sgo.is_active = 1 AND sgo.objecttype_id = 4', array() ); - $this->group(array('sd.scheduleddowntime_id', 'so.name2', 'so.name1')); } /** @@ -172,4 +170,33 @@ class ServicedowntimeQuery extends IdoQuery array() ); } + + /** + * {@inheritdoc} + */ + public function getGroup() + { + $group = array(); + if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('servicegroups')) { + $group = array('sd.scheduleddowntime_id', 'so.object_id'); + + if ($this->hasJoinedVirtualTable('hosts')) { + $group[] = 'h.host_id'; + } + + if ($this->hasJoinedVirtualTable('hoststatus')) { + $group[] = 'hs.hoststatus_id'; + } + + if ($this->hasJoinedVirtualTable('services')) { + $group[] = 's.service_id'; + } + + if ($this->hasJoinedVirtualTable('servicestatus')) { + $group[] = 'ss.servicestatus_id'; + } + } + + return $group; + } }