diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 6aeda5abea..261f709d4b 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -77,7 +77,7 @@ $databaseListener = function (string $event, Document $document, Stats $usage) { } elseif (strpos($collection, 'database_') === 0) { $usage ->setParam('databaseId', $document->getAttribute('databaseId')); - if (strpos($collection, '_collection_') != false) { + if (strpos($collection, '_collection_') !== false) { $usage ->setParam('collectionId', $document->getAttribute('$collectionId')) ->setParam('documents.{scope}.count.total', 1 * $multiplier); diff --git a/src/Appwrite/Usage/Stats.php b/src/Appwrite/Usage/Stats.php index 510584c875..e6e0056664 100644 --- a/src/Appwrite/Usage/Stats.php +++ b/src/Appwrite/Usage/Stats.php @@ -110,7 +110,7 @@ class Stats foreach ($usersMetrics as $metric) { $value = $this->params[$metric] ?? 0; - if ($value == 1 || $value == -1) { + if ($value === 1 || $value === -1) { $this->statsd->count($metric . $tags, $value); } } @@ -135,7 +135,7 @@ class Stats foreach ($dbMetrics as $metric) { $value = $this->params[$metric] ?? 0; - if ($value == 1 || $value == -1) { + if ($value === 1 || $value === -1) { $dbTags = $tags . ",collectionId=" . ($this->params['collectionId'] ?? '') . ",databaseId=" . ($this->params['databaseId'] ?? ''); $this->statsd->count($metric . $dbTags, $value); } @@ -157,7 +157,7 @@ class Stats foreach ($storageMertics as $metric) { $value = $this->params[$metric] ?? 0; - if ($value >= 1 || $value == -1 || $value < -1) { + if ($value !== 0) { $storageTags = $tags . ",bucketId=" . ($this->params['bucketId'] ?? ''); $this->statsd->count($metric . $storageTags, $value); } @@ -194,7 +194,7 @@ class Stats $this->statsd->count('project.{scope}.storage.size' . $tags, $deploymentSize + $storageSize); } - if ($deploymentSize > 0 || $deploymentSize <= -1) { + if ($deploymentSize !== 0) { $this->statsd->count('deployments.{scope}.storage.size' . $functionTags, $deploymentSize); }