Skip to content

Commit

Permalink
HostnotificationQuery: PostgreSQL grouping...
Browse files Browse the repository at this point in the history
refs #9009
  • Loading branch information
Johannes Meyer committed Jun 18, 2015
1 parent 068c0b6 commit 8ec494c
Showing 1 changed file with 29 additions and 8 deletions.
Expand Up @@ -124,7 +124,6 @@ protected function joinBaseTables()
protected function joinHistory()
{
$this->requireVirtualTable('contactnotifications');
$this->group(array('hn.notification_id', 'ho.name1'));
}

/**
Expand All @@ -142,7 +141,6 @@ protected function joinContactnotifications()
'cno.object_id = cn.contact_object_id',
array()
);
$this->group(array('cn.contactnotification_id', 'ho.name1'));
}

/**
Expand Down Expand Up @@ -175,10 +173,6 @@ protected function joinHostgroups()
'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('hn.notification_id', 'ho.name1'));
}
}

/**
Expand Down Expand Up @@ -228,9 +222,36 @@ protected function joinServices()
'so.object_id = s.service_object_id AND so.is_active = 1 AND so.objecttype_id = 2',
array()
);
}

if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$this->group(array('hn.notification_id', 'ho.name1'));
/**
* {@inheritdoc}
*/
public function getGroup()
{
if (
$this->hasJoinedVirtualTable('history')
|| $this->hasJoinedVirtualTable('services')
|| $this->hasJoinedVirtualTable('hostgroups')
) {
$group = array('hn.notification_id', 'ho.object_id');
if ($this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$group[] = 'cno.object_id';
}
} elseif ($this->hasJoinedVirtualTable('contactnotifications')) {
$group = array('hn.notification_id', 'cno.object_id', 'ho.object_id');
}

if (! empty($group)) {
if ($this->hasJoinedVirtualTable('hosts')) {
$group[] = 'h.host_id';
}

if ($this->hasJoinedVirtualTable('acknowledgements')) {
$group[] = 'a.acknowledgement_id';
}
}

return $group;
}
}

0 comments on commit 8ec494c

Please sign in to comment.