From cdc9a6354b3eb636fa3861cb4873167b09795892 Mon Sep 17 00:00:00 2001 From: mh-er <119431967+mh-er@users.noreply.github.com> Date: Thu, 27 Apr 2023 19:09:23 +0200 Subject: [PATCH] Improved fix of #923 "aggregate fails due to division by zero" I improved the solution due to the comment of andig. --- lib/Util/Aggregation.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Util/Aggregation.php b/lib/Util/Aggregation.php index be7696e2..8ff19a61 100644 --- a/lib/Util/Aggregation.php +++ b/lib/Util/Aggregation.php @@ -255,9 +255,7 @@ protected function aggregateChannel($channel_id, $interpreter, $mode, $level, $p // since last aggregation only array_push($sqlParameters, $type, $channel_id); $intialTimestamp = - 'UNIX_TIMESTAMP(DATE_ADD(' . - 'FROM_UNIXTIME(MAX(timestamp) / 1000, "%Y-%m-%d %H:%i:%s"), ' . - 'INTERVAL 0 ' . $level . ')) * 1000 ' . + 'MAX(timestamp) ' . 'FROM aggregate ' . 'WHERE type = ? AND aggregate.channel_id = ?'; } elseif ($period) {