From dab90d6c4a0d9e3b6d66dcbbd96bcea499d0cee8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 17 Jun 2014 12:42:50 +0000 Subject: [PATCH] GroupsummaryQuery: distinct columns/desiredColumns I guess this needs some more investigation, desiredColumns are the ones the user asked for ([alias => ]column), with column being once again an alias in the "real" query. Alias resolution used to work better long time ago, we should reflect on this. --- .../Backend/Ido/Query/GroupsummaryQuery.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index fe60db444..72ce448bd 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -71,8 +71,9 @@ class GroupSummaryQuery extends IdoQuery 'host_state', 'host_name' ); + // Prepend group column since we'll use columns index 0 later for grouping - if (in_array('servicegroup', $this->getColumns())) { + if (in_array('servicegroup', $this->desiredColumns)) { array_unshift($columns, 'servicegroup'); } else { array_unshift($columns, 'hostgroup'); @@ -80,21 +81,22 @@ class GroupSummaryQuery extends IdoQuery $hosts = $this->createSubQuery( 'Hoststatus', $columns + array( - 'state' => 'host_state', - 'acknowledged' => 'host_acknowledged', - 'in_downtime' => 'host_in_downtime' + 'state' => 'host_state', + 'acknowledged' => 'host_acknowledged', + 'in_downtime' => 'host_in_downtime' ) ); $services = $this->createSubQuery( 'Status', $columns + array( - 'state' => 'service_state', - 'acknowledged' => 'service_acknowledged', - 'in_downtime' => 'service_in_downtime' + 'state' => 'service_state', + 'acknowledged' => 'service_acknowledged', + 'in_downtime' => 'service_in_downtime' ) ); + $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); - $this->select->from(array('statussummary' => $union), array())->group($columns[0]); + $this->select->from(array('statussummary' => $union), '*')->group($columns[0]); $this->joinedVirtualTables = array( 'servicestatussummary' => true, 'hoststatussummary' => true