diff --git a/library/Icingadb/Common/IcingaRedis.php b/library/Icingadb/Common/IcingaRedis.php index a22a0f03b..84264815b 100644 --- a/library/Icingadb/Common/IcingaRedis.php +++ b/library/Icingadb/Common/IcingaRedis.php @@ -8,6 +8,7 @@ use Generator; use Icinga\Application\Config; use Icinga\Application\Logger; +use ipl\Sql\Expression; use Predis\Client as Redis; class IcingaRedis @@ -163,7 +164,16 @@ protected static function fetchState(string $key, array $ids, array $columns): G foreach ($results as $i => $json) { if ($json !== null) { $data = json_decode($json, true); - $keyMap = array_fill_keys($columns, null); + $keyMap = []; + + foreach ($columns as $alias => $column) { + if ($column instanceof Expression) { + $keyMap[$alias] = $column->getStatement() ; + } else { + $keyMap[$alias] = null; + } + } + unset($keyMap['is_overdue']); // Is calculated by Icinga DB, not Icinga 2, hence it's never in redis // TODO: Remove once https://github.com/Icinga/icinga2/issues/9427 is fixed diff --git a/library/Icingadb/Model/Host.php b/library/Icingadb/Model/Host.php index 05c35bc07..57eef2b5a 100644 --- a/library/Icingadb/Model/Host.php +++ b/library/Icingadb/Model/Host.php @@ -13,6 +13,7 @@ use ipl\Orm\Model; use ipl\Orm\Relations; use ipl\Orm\ResultSet; +use ipl\Sql\Expression; /** * Host model. @@ -113,7 +114,7 @@ public function getColumns() 'zone_id', 'command_endpoint_name', 'command_endpoint_id', - 'affected_children' + 'affected_children' => new Expression('200000') ]; } diff --git a/library/Icingadb/Model/Service.php b/library/Icingadb/Model/Service.php index d895789ec..2cf7ab89b 100644 --- a/library/Icingadb/Model/Service.php +++ b/library/Icingadb/Model/Service.php @@ -14,6 +14,7 @@ use ipl\Orm\Model; use ipl\Orm\Relations; use ipl\Orm\ResultSet; +use ipl\Sql\Expression; /** * @property string $id @@ -106,7 +107,7 @@ public function getColumns() 'zone_id', 'command_endpoint_name', 'command_endpoint_id', - 'affected_children' + 'affected_children' => new Expression('10') ]; } diff --git a/library/Icingadb/Model/State.php b/library/Icingadb/Model/State.php index a4556c1d5..fa2eab6e7 100644 --- a/library/Icingadb/Model/State.php +++ b/library/Icingadb/Model/State.php @@ -11,6 +11,7 @@ use ipl\Orm\Behavior\MillisecondTimestamp; use ipl\Orm\Behaviors; use ipl\Orm\Model; +use ipl\Sql\Expression; use ipl\Web\Widget\Icon; /** @@ -100,7 +101,7 @@ public function getColumns() 'last_state_change', 'next_check', 'next_update', - 'affects_children' + 'affects_children' => new Expression("'y'") ]; }