1
0
Fork 0
mirror of synced 2024-08-28 16:41:39 +12:00

moved reduce after delete document to usage-worker

This commit is contained in:
shimon 2022-12-28 20:06:57 +02:00
parent 4198cbfca5
commit db8b24ee22

View file

@ -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 case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections
$parts = explode('_', $document->getCollection()); $parts = explode('_', $document->getCollection());
$databaseId = $parts[1] ?? 0; $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'])) { if (!empty($documents['value'])) {
$metrics[] = [ $metrics[] = [
'key' => 'documents', 'key' => 'documents',
'value' => ($documents['value'] * -1), 'value' => ($documents['value'] * -1),
]; ];
$metrics[] = [
'key' => "{$databaseId}" . ".documents",
'value' => ($documents['value'] * -1),
];
} }
break; break;