From db8b24ee229dd0f102fe249889b6a8b8dd984ed4 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 28 Dec 2022 20:06:57 +0200 Subject: [PATCH] moved reduce after delete document to usage-worker --- app/workers/usage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/workers/usage.php b/app/workers/usage.php index a3f707b41a..ca54f7663c 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -69,12 +69,17 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections $parts = explode('_', $document->getCollection()); $databaseId = $parts[1] ?? 0; - $documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$databaseId}" . ".documents")); + $documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$databaseId}" . "." . "{$document->getInternalId()}" . ".documents")); + if (!empty($documents['value'])) { $metrics[] = [ 'key' => 'documents', 'value' => ($documents['value'] * -1), ]; + $metrics[] = [ + 'key' => "{$databaseId}" . ".documents", + 'value' => ($documents['value'] * -1), + ]; } break;