From 12bf434f6aad1a82efdc75bc0a5ff5fa32ddfa1e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Apr 2025 09:08:00 +0000 Subject: [PATCH] fix division by 0 --- src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php index 94eed94a17..7f64fa8d8c 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php @@ -126,6 +126,8 @@ class Get extends Base } } + $buildsTimeTotal = $usage[$metrics[4]]['total'] ?? 0; + $buildsTotal = $usage[$metrics[2]]['total'] ?? 0; $response->dynamic(new Document([ 'range' => $range, 'deploymentsTotal' => $usage[$metrics[0]]['total'], @@ -135,7 +137,7 @@ class Get extends Base 'buildsFailedTotal' => $usage[$metrics[10]]['total'], 'buildsStorageTotal' => $usage[$metrics[3]]['total'], 'buildsTimeTotal' => $usage[$metrics[4]]['total'], - 'buildsTimeAverage' => (int) ($usage[$metrics[4]]['total'] / $usage[$metrics[2]]['total']), + 'buildsTimeAverage' => $buildsTotal === 0 ? 0 : (int) ($buildsTimeTotal / $buildsTotal), 'executionsTotal' => $usage[$metrics[5]]['total'], 'executionsTimeTotal' => $usage[$metrics[6]]['total'], 'buildsMbSecondsTotal' => $usage[$metrics[7]]['total'],