ServicenotificationQuery: PostgreSQL grouping...

refs #9009
This commit is contained in:
Johannes Meyer 2015-06-18 10:59:52 +02:00
parent 8ec494c962
commit 4f42da49a8
1 changed files with 36 additions and 10 deletions

View File

@ -125,7 +125,6 @@ class ServicenotificationQuery extends IdoQuery
protected function joinHistory()
{
$this->requireVirtualTable('contactnotifications');
$this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
}
/**
@ -143,7 +142,6 @@ class ServicenotificationQuery extends IdoQuery
'cno.object_id = cn.contact_object_id',
array()
);
$this->group(array('cn.contactnotification_id', 'so.name2', 'so.name1'));
}
/**
@ -177,10 +175,6 @@ class ServicenotificationQuery extends IdoQuery
'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3',
array()
);
if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
}
}
/**
@ -214,10 +208,6 @@ class ServicenotificationQuery extends IdoQuery
'sgo.object_id = sg.servicegroup_object_id AND sgo.is_active = 1 AND sgo.objecttype_id = 4',
array()
);
if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
}
}
/**
@ -231,4 +221,40 @@ class ServicenotificationQuery extends IdoQuery
array()
);
}
/**
* {@inheritdoc}
*/
public function getGroup()
{
$group = array();
if (
$this->hasJoinedVirtualTable('history')
|| $this->hasJoinedVirtualTable('hostgroups')
|| $this->hasJoinedVirtualTable('servicegroups')
) {
$group = array('sn.notification_id', 'so.object_id');
if ($this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$group[] = 'cno.object_id';
}
} elseif ($this->hasJoinedVirtualTable('contactnotifications')) {
$group = array('sn.notification_id', 'cno.object_id', 'so.object_id');
}
if (! empty($group)) {
if ($this->hasJoinedVirtualTable('hosts')) {
$group[] = 'h.host_id';
}
if ($this->hasJoinedVirtualTable('services')) {
$group[] = 's.service_id';
}
if ($this->hasJoinedVirtualTable('acknowledgements')) {
$group[] = 'a.acknowledgement_id';
}
}
return $group;
}
}