From 9179a7099251b3f811b7d2ed5131bf18e86a3f42 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 13:37:16 +0300 Subject: [PATCH 1/5] 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'); } From 0a92e3dc552c9825867815d9723d5388e6bdb508 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 13:54:04 +0300 Subject: [PATCH 2/5] fix --- src/Appwrite/Platform/Tasks/CalcTierStats.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index 5b262b0601..5553858d3f 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -104,10 +104,7 @@ class CalcTierStats extends Action /** * Skip user projects with id 'console' */ - if ( - $project->getId() === 'console' || - empty($project) - ) { + if ($project->getId() === 'console') continue; } From 5e836691e245de474a2c491fba131ecabc834537 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 13:55:16 +0300 Subject: [PATCH 3/5] fix --- src/Appwrite/Platform/Tasks/CalcTierStats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index 5553858d3f..1195103db8 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -104,7 +104,7 @@ class CalcTierStats extends Action /** * Skip user projects with id 'console' */ - if ($project->getId() === 'console') + if ($project->getId() === 'console') { continue; } From 9ff6faa2d22686337497ba42351045851ab56968 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 15:50:48 +0300 Subject: [PATCH 4/5] fix --- src/Appwrite/Platform/Tasks/CalcTierStats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index 1195103db8..a80fea7406 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -252,7 +252,7 @@ class CalcTierStats extends Action $csv->insertOne(array_values($stats)); } catch (\Throwable $th) { - Console::error('Failed to update project ("' . $project->getId() . '") version with error: ' . $th->getMessage()); + Console::error('Failed to update project ("' . $project->getId() . '") version with error on line no: ' . $th->getline() . 'with message: ' . $th->getMessage()); } finally { $pools ->get($db) From 38cf901579a03f4a6a381443ac90ae899af2c24a Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 19 Jun 2023 17:30:21 +0300 Subject: [PATCH 5/5] fix --- src/Appwrite/Platform/Tasks/CalcTierStats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index a80fea7406..4e525e709b 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -252,7 +252,7 @@ class CalcTierStats extends Action $csv->insertOne(array_values($stats)); } catch (\Throwable $th) { - Console::error('Failed to update project ("' . $project->getId() . '") version with error on line no: ' . $th->getline() . 'with message: ' . $th->getMessage()); + Console::error('Failed on project ("' . $project->getId() . '") version with error on line no: ' . $th->getline() . 'with message: ' . $th->getMessage()); } finally { $pools ->get($db)