From d39165889e1a633f6d2aa3ee7828b53d1cbf026e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 14 Jun 2022 00:40:33 +0000 Subject: [PATCH] error fixes --- src/Appwrite/Stats/Usage.php | 4 ++-- src/Appwrite/Stats/UsageDB.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Stats/Usage.php b/src/Appwrite/Stats/Usage.php index e5901ba8f9..ba1209faf9 100644 --- a/src/Appwrite/Stats/Usage.php +++ b/src/Appwrite/Stats/Usage.php @@ -186,7 +186,7 @@ class Usage if ($document->isEmpty()) { $this->database->createDocument('stats', new Document([ '$id' => $id, - 'period' => $period['key'], + 'period' => $period, 'time' => $time, 'metric' => $metric, 'value' => $value, @@ -199,7 +199,7 @@ class Usage $document->setAttribute('value', $value) ); } - $this->latestTime[$metric][$period['key']] = $time; + $this->latestTime[$metric][$period] = $time; } catch (\Exception $e) { // if projects are deleted this might fail if (is_callable($this->errorHandler)) { call_user_func($this->errorHandler, "Unable to save data for project {$projectId} and metric {$metric}: {$e->getMessage()}", $e->getTraceAsString()); diff --git a/src/Appwrite/Stats/UsageDB.php b/src/Appwrite/Stats/UsageDB.php index 7165245497..b47956af82 100644 --- a/src/Appwrite/Stats/UsageDB.php +++ b/src/Appwrite/Stats/UsageDB.php @@ -34,7 +34,7 @@ class UsageDB extends Usage if ($document->isEmpty()) { $this->database->createDocument('stats', new Document([ '$id' => $id, - 'period' => $period['key'], + 'period' => $period, 'time' => $time, 'metric' => $metric, 'value' => $value, @@ -179,7 +179,7 @@ class UsageDB extends Usage $this->foreachDocument($projectId, 'buckets', [], function ($bucket) use (&$projectFilesCount, &$projectFilesTotal, $projectId,) { $metric = "storage.buckets.{$bucket->getId()}.files.count"; - $count = $this->count($projectId, 'buckets_' . $bucket->getInternalId(), $metric); + $count = $this->count($projectId, 'bucket_' . $bucket->getInternalId(), $metric); $projectFilesCount += $count; $metric = "storage.buckets.{$bucket->getId()}.files.total";