From cbaa2d8ae93e815ec8d44e304ff56714ffeb9d22 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 5 Sep 2014 18:41:51 +0200 Subject: [PATCH] StateHistoryQuery: tune type queries --- .../Monitoring/Backend/Ido/Query/StatehistoryQuery.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php index 81d7e662c..75b5ab284 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php @@ -6,6 +6,11 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; class StatehistoryQuery extends IdoQuery { + protected $types = array( + 'soft_state' => 0, + 'hard_state' => 1, + ); + protected $columnMap = array( 'statehistory' => array( 'raw_timestamp' => 'sh.state_time', @@ -33,6 +38,8 @@ class StatehistoryQuery extends IdoQuery { if ($col === 'UNIX_TIMESTAMP(sh.state_time)') { return 'sh.state_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); + } elseif ($col === $this->columnMap['statehistory']['type']) { + return 'sh.state_type ' . $sign . ' ' . $this->types[$expression]; } else { return parent::whereToSql($col, $sign, $expression); }