More comment query cleanup and fix a typo
This commit is contained in:
parent
1659df216d
commit
2f61075260
|
@ -327,9 +327,9 @@ class Monitoring_ListController extends Controller
|
||||||
'timestamp' => 'comment_timestamp',
|
'timestamp' => 'comment_timestamp',
|
||||||
'type' => 'comment_type',
|
'type' => 'comment_type',
|
||||||
'persistent' => 'comment_is_persistent',
|
'persistent' => 'comment_is_persistent',
|
||||||
'expiration' => 'comment_expiration_timestamp',
|
'expiration' => 'comment_expiration',
|
||||||
'host',
|
'host' => 'comment_host',
|
||||||
'service'
|
'service' => 'comment_service'
|
||||||
)
|
)
|
||||||
)->getQuery();
|
)->getQuery();
|
||||||
|
|
||||||
|
@ -338,9 +338,9 @@ class Monitoring_ListController extends Controller
|
||||||
$this->setupSortControl(
|
$this->setupSortControl(
|
||||||
array(
|
array(
|
||||||
'comment_timestamp' => 'Comment Timestamp',
|
'comment_timestamp' => 'Comment Timestamp',
|
||||||
'host_name' => 'Host / Service',
|
'comment_host' => 'Host / Service',
|
||||||
'comment_type' => 'Comment Type',
|
'comment_type' => 'Comment Type',
|
||||||
'comment_expiration_timestamp' => 'Expiration',
|
'comment_expiration' => 'Expiration',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->handleFormatRequest($query);
|
$this->handleFormatRequest($query);
|
||||||
|
|
|
@ -36,23 +36,16 @@ class CommentQuery extends IdoQuery
|
||||||
{
|
{
|
||||||
protected $columnMap = array(
|
protected $columnMap = array(
|
||||||
'comments' => array(
|
'comments' => array(
|
||||||
'comment_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END",
|
'comment_internal_id' => 'cm.internal_comment_id',
|
||||||
'comment_internal_id' => 'cm.internal_comment_id',
|
'comment_data' => 'cm.comment_data',
|
||||||
'comment_data' => 'cm.comment_data',
|
'comment_author' => 'cm.author_name COLLATE latin1_general_ci',
|
||||||
'comment_author' => 'cm.author_name COLLATE latin1_general_ci',
|
'comment_timestamp' => 'UNIX_TIMESTAMP(cm.comment_time)',
|
||||||
'comment_timestamp' => 'UNIX_TIMESTAMP(cm.comment_time)',
|
'comment_type' => "CASE cm.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'downtime' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END",
|
||||||
'comment_type' => "CASE cm.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'downtime' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END",
|
'comment_is_persistent' => 'cm.is_persistent',
|
||||||
'comment_is_persistent' => 'cm.is_persistent',
|
'comment_expiration' => 'CASE cm.expires WHEN 1 THEN UNIX_TIMESTAMP(cm.expiration_time) ELSE NULL END',
|
||||||
'comment_expiration_timestamp' => 'CASE cm.expires WHEN 1 THEN UNIX_TIMESTAMP(cm.expiration_time) ELSE NULL END',
|
'comment_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci',
|
||||||
),
|
'comment_service' => 'so.name2 COLLATE latin1_general_ci',
|
||||||
'hosts' => array(
|
'comment_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END",
|
||||||
'host_name' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci',
|
|
||||||
'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci',
|
|
||||||
),
|
|
||||||
'services' => array(
|
|
||||||
'service' => 'so.name2 COLLATE latin1_general_ci',
|
|
||||||
'service_name' => 'so.name2 COLLATE latin1_general_ci',
|
|
||||||
'service_description' => 'so.name2 COLLATE latin1_general_ci',
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -62,37 +55,17 @@ class CommentQuery extends IdoQuery
|
||||||
array('cm' => $this->prefix . 'comments'),
|
array('cm' => $this->prefix . 'comments'),
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
$this->baseQuery->join(
|
|
||||||
array(
|
|
||||||
'co' => $this->prefix . 'objects'
|
|
||||||
),
|
|
||||||
'cm.object_id = co.' . $this->object_id . ' AND co.is_active = 1'
|
|
||||||
);*/
|
|
||||||
|
|
||||||
$this->joinedVirtualTables = array('comments' => true);
|
|
||||||
$this->joinVirtualTable('hosts');
|
|
||||||
$this->joinVirtualTable('services');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function joinHosts()
|
|
||||||
{
|
|
||||||
// $this->conflictsWithVirtualTable('services');
|
|
||||||
$this->baseQuery->joinLeft(
|
$this->baseQuery->joinLeft(
|
||||||
array('ho' => $this->prefix . 'objects'),
|
array('ho' => $this->prefix . 'objects'),
|
||||||
'cm.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
|
'cm.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
protected function joinServices()
|
|
||||||
{
|
|
||||||
// $this->conflictsWithVirtualTable('hosts');
|
|
||||||
$this->baseQuery->joinLeft(
|
$this->baseQuery->joinLeft(
|
||||||
array('so' => $this->prefix . 'objects'),
|
array('so' => $this->prefix . 'objects'),
|
||||||
'cm.object_id = so.object_id AND so.is_active = 1 AND so.objecttype_id = 2',
|
'cm.object_id = so.object_id AND so.is_active = 1 AND so.objecttype_id = 2',
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
$this->joinedVirtualTables = array('comments' => true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ class Comment extends DataView
|
||||||
'comment_timestamp',
|
'comment_timestamp',
|
||||||
'comment_type',
|
'comment_type',
|
||||||
'comment_is_persistent',
|
'comment_is_persistent',
|
||||||
'comment_expiration_timestamp',
|
'comment_expiration',
|
||||||
'host_name',
|
'comment_host',
|
||||||
'service_description',
|
'comment_service',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ class Comment extends DataView
|
||||||
'comment_timestamp' => array(
|
'comment_timestamp' => array(
|
||||||
'order' => self::SORT_DESC
|
'order' => self::SORT_DESC
|
||||||
),
|
),
|
||||||
'host_name' => array(
|
'comment_host' => array(
|
||||||
'columns' => array(
|
'columns' => array(
|
||||||
'host_name',
|
'comment_host',
|
||||||
'service_description'
|
'comment_service'
|
||||||
),
|
),
|
||||||
'order' => self::SORT_ASC
|
'order' => self::SORT_ASC
|
||||||
),
|
),
|
||||||
|
|
|
@ -52,9 +52,9 @@ abstract class AbstractObject
|
||||||
))->getQuery();
|
))->getQuery();
|
||||||
$query->where('comment_type', array('comment', 'ack'));
|
$query->where('comment_type', array('comment', 'ack'));
|
||||||
$query->where('comment_objecttype', $this->type);
|
$query->where('comment_objecttype', $this->type);
|
||||||
$query->where('host_name', $this->host_name);
|
$query->where('comment_host', $this->host_name);
|
||||||
if ($this->type === 'service') {
|
if ($this->type === 'service') {
|
||||||
$query->where('service_description', $this->service_description);
|
$query->where('comment_service', $this->service_description);
|
||||||
}
|
}
|
||||||
$this->comments = $query->fetchAll();
|
$this->comments = $query->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use Icinga\Data\Db\Query;
|
||||||
|
|
||||||
class Host extends AbstractObject
|
class Host extends AbstractObject
|
||||||
{
|
{
|
||||||
public $typ = 'host';
|
public $type = 'host';
|
||||||
public $prefix = 'host_';
|
public $prefix = 'host_';
|
||||||
private $view = null;
|
private $view = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue