From 7ec1af46409b469d2f14528af6a3d93249c6f469 Mon Sep 17 00:00:00 2001 From: eliseekn Date: Sun, 21 Apr 2024 10:36:58 +0000 Subject: [PATCH] Fix date function by database driver Fix metrics negative variation value display --- src/DatesFunctions.php | 2 +- src/LaravelMetrics.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DatesFunctions.php b/src/DatesFunctions.php index 5fa3043..d485e97 100644 --- a/src/DatesFunctions.php +++ b/src/DatesFunctions.php @@ -91,7 +91,7 @@ protected function formatDateColumn(): string return match ($driver) { 'mysql' => "date($this->dateColumn)", 'pgsql' => "TO_CHAR($this->dateColumn, 'YYYY-MM-DD')", - 'default' => "strftime('%Y-%m-%d', $this->dateColumn)", + default => "strftime('%Y-%m-%d', $this->dateColumn)", }; } diff --git a/src/LaravelMetrics.php b/src/LaravelMetrics.php index b61b695..3439b6c 100644 --- a/src/LaravelMetrics.php +++ b/src/LaravelMetrics.php @@ -713,7 +713,7 @@ public function metricsWithVariations(int $previousCount, string $previousPeriod } elseif ($value < 0) { $result['variation'] = [ 'type' => 'decrease', - 'value' => $value, + 'value' => abs($value), ]; }