From 99b0d63e941171246a1f215f5f131e4006ee55e8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 18 Jun 2015 11:17:14 +0200 Subject: [PATCH] HostcommentQuery: PostgreSQL grouping... refs #9009 --- .../Backend/Ido/Query/HostcommentQuery.php | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php index d73d99ece..63b76fa22 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php @@ -88,7 +88,6 @@ class HostcommentQuery extends IdoQuery 'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3', array() ); - $this->group(array('c.comment_id', 'ho.name1')); } /** @@ -150,6 +149,25 @@ class HostcommentQuery extends IdoQuery 'so.object_id = s.service_object_id AND so.is_active = 1 AND so.objecttype_id = 2', array() ); - $this->group(array('c.comment_id', 'ho.name1')); + } + + /** + * {@inheritdoc} + */ + public function getGroup() + { + $group = array(); + if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('servicegroups')) { + $group = array('c.comment_id', 'ho.object_id'); + if ($this->hasJoinedVirtualTable('hosts')) { + $group[] = 'h.host_id'; + } + + if ($this->hasJoinedVirtualTable('hoststatus')) { + $group[] = 'hs.hoststatus_id'; + } + } + + return $group; } }