From 7b5d7bdbcf93fa72bd155b87e15f9dd201a95561 Mon Sep 17 00:00:00 2001
From: Thomas Gelf <thomas@gelf.net>
Date: Sat, 21 Jun 2014 03:18:00 +0200
Subject: [PATCH] monitoring/statehistorysummary: filter fixes

Slightly adjusted filter string to fit new filters, fixed an issue
with 'object_type' column in virtual eventhistory table.
---
 .../application/views/scripts/list/statehistorysummary.phtml   | 2 +-
 .../Backend/Ido/Query/CommentdeletionhistoryQuery.php          | 3 ++-
 .../Monitoring/Backend/Ido/Query/CommenthistoryQuery.php       | 3 ++-
 .../Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php   | 3 ++-
 .../Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php | 3 ++-
 .../library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php | 3 ++-
 .../Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php  | 3 ++-
 .../library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php | 3 ++-
 8 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml
index f72e5d274..40fd6fd2c 100644
--- a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml
+++ b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml
@@ -22,7 +22,7 @@ foreach ($summary as $entry) {
                 'timestamp>'  => strtotime($day . ' 00:00:00'),
                 'object_type' => 'service',
                 'state'       => '2',
-                'type'        => 'hard_state,soft_state'
+                'type'        => '(hard_state|soft_state)'
             )
         )
     );
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentdeletionhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentdeletionhistoryQuery.php
index e982bf9b6..3d3ffdf65 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentdeletionhistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentdeletionhistoryQuery.php
@@ -22,7 +22,8 @@ class CommentdeletionhistoryQuery extends IdoQuery
             'host_name'           => 'o.name1 COLLATE latin1_general_ci',
             'service_description' => 'o.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'o.name1 COLLATE latin1_general_ci',
-            'service_description' => 'o.name2 COLLATE latin1_general_ci'
+            'service_description' => 'o.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN o.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );
 
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php
index e05a68289..7b3929f3e 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommenthistoryQuery.php
@@ -22,7 +22,8 @@ class CommenthistoryQuery extends IdoQuery
             'host_name'           => 'o.name1 COLLATE latin1_general_ci',
             'service_description' => 'o.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'o.name1 COLLATE latin1_general_ci',
-            'service_description' => 'o.name2 COLLATE latin1_general_ci'
+            'service_description' => 'o.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN o.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );
 
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php
index b03da76dc..75998e3de 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php
@@ -22,7 +22,8 @@ class DowntimeendhistoryQuery extends IdoQuery
             'host_name'           => 'o.name1 COLLATE latin1_general_ci',
             'service_description' => 'o.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'o.name1 COLLATE latin1_general_ci',
-            'service_description' => 'o.name2 COLLATE latin1_general_ci'
+            'service_description' => 'o.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN o.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );
 
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php
index e46828e82..4dc165a60 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php
@@ -22,7 +22,8 @@ class DowntimestarthistoryQuery extends IdoQuery
             'host_name'           => 'o.name1 COLLATE latin1_general_ci',
             'service_description' => 'o.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'o.name1 COLLATE latin1_general_ci',
-            'service_description' => 'o.name2 COLLATE latin1_general_ci'
+            'service_description' => 'o.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN o.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );
 
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php
index 508d04b07..c4f7f753e 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php
@@ -20,7 +20,7 @@ class EventHistoryQuery extends IdoQuery
             'service'             => 'eho.name2 COLLATE latin1_general_ci',
             'host_name'           => 'eho.name1 COLLATE latin1_general_ci',
             'service_description' => 'eho.name2 COLLATE latin1_general_ci',
-            'object_type'         => "CASE WHEN eho.objecttype_id = 1 THEN 'host' ELSE 'service' END",
+            'object_type'         => 'eh.object_type',
             'timestamp'           => 'eh.timestamp',
             'state'               => 'eh.state',
             'attempt'             => 'eh.attempt',
@@ -46,6 +46,7 @@ class EventHistoryQuery extends IdoQuery
             'output',
             'state',
             'state_type',
+            'object_type',
             'attempt',
             'max_attempts',
         );
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php
index 06408cf66..7abb466ca 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php
@@ -22,7 +22,8 @@ class NotificationhistoryQuery extends IdoQuery
             'host_name'           => 'o.name1 COLLATE latin1_general_ci',
             'service_description' => 'o.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'o.name1 COLLATE latin1_general_ci',
-            'service_description' => 'o.name2 COLLATE latin1_general_ci'
+            'service_description' => 'o.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN o.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );
 
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php
index 47163519f..fffd0d4e5 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php
@@ -22,7 +22,8 @@ class StatehistoryQuery extends IdoQuery
             'host_name'           => 'sho.name1 COLLATE latin1_general_ci',
             'service_description' => 'sho.name2 COLLATE latin1_general_ci',
             'service_host_name'   => 'sho.name1 COLLATE latin1_general_ci',
-            'service_description' => 'sho.name2 COLLATE latin1_general_ci'
+            'service_description' => 'sho.name2 COLLATE latin1_general_ci',
+            'object_type'         => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END"
         )
     );