From 9179a7099251b3f811b7d2ed5131bf18e86a3f42 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 13:37:16 +0300 Subject: [PATCH] fix --- src/Appwrite/Platform/Tasks/CalcTierStats.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index bdc46e9780..5b262b0601 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -104,7 +104,10 @@ class CalcTierStats extends Action /** * Skip user projects with id 'console' */ - if ($project->getId() === 'console') { + if ( + $project->getId() === 'console' || + empty($project) + ) { continue; } @@ -175,6 +178,10 @@ class CalcTierStats extends Action $tmp[$metric] = []; foreach ($requestDocs as $requestDoc) { + if (empty($requestDoc)) { + continue; + } + $tmp[$metric][] = [ 'value' => $requestDoc->getAttribute('value'), 'date' => $requestDoc->getAttribute('time'), @@ -218,9 +225,12 @@ class CalcTierStats extends Action $buckets = $dbForProject->find('buckets', []); $counter = 0; foreach ($buckets as $bucket) { + $file = $dbForProject->findOne('bucket_' . $bucket->getInternalId(), [Query::orderDesc('sizeOriginal'),]); + if (empty($file)) { + continue; + } $filesSum += $dbForProject->sum('bucket_' . $bucket->getInternalId(), 'sizeOriginal', [], 0); $filesCount += $dbForProject->count('bucket_' . $bucket->getInternalId(), []); - $file = $dbForProject->findOne('bucket_' . $bucket->getInternalId(), [Query::orderDesc('sizeOriginal'),]); if ($file->getAttribute('sizeOriginal') > $maxFileSize) { $maxFileSize = $file->getAttribute('sizeOriginal'); }