Merge branch '1.6.x' into feat-usage-dump-multi-tenant-batch

This commit is contained in:
Damodar Lohani 2025-04-15 10:44:47 +05:45 committed by GitHub
commit 969c58fda9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 34 additions and 43 deletions

View file

@ -51,7 +51,7 @@
"utopia-php/cache": "0.12.*",
"utopia-php/cli": "0.15.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "0.64.*",
"utopia-php/database": "0.65.*",
"utopia-php/domains": "0.5.*",
"utopia-php/dsn": "0.2.1",
"utopia-php/framework": "0.33.*",

38
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6a54c8bc4f9f14cd3883f55880864630",
"content-hash": "51ff891ef6cee8a3f8c4e5187b7fd479",
"packages": [
{
"name": "adhocore/jwt",
@ -3497,16 +3497,16 @@
},
{
"name": "utopia-php/database",
"version": "0.64.2",
"version": "0.65.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd"
"reference": "e589efdc5da1216523a758e8af358866d4fb563f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/dc9c4a68c93e8bea2dfaa76d1ba308be539998bd",
"reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd",
"url": "https://api.github.com/repos/utopia-php/database/zipball/e589efdc5da1216523a758e8af358866d4fb563f",
"reference": "e589efdc5da1216523a758e8af358866d4fb563f",
"shasum": ""
},
"require": {
@ -3547,9 +3547,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.64.2"
"source": "https://github.com/utopia-php/database/tree/0.65.0"
},
"time": "2025-04-09T07:53:05+00:00"
"time": "2025-04-14T07:39:01+00:00"
},
{
"name": "utopia-php/domains",
@ -3660,16 +3660,16 @@
},
{
"name": "utopia-php/fetch",
"version": "0.4.0",
"version": "0.4.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/fetch.git",
"reference": "46e791ff6a95864517750b9df6bbf4a17e3c9c4e"
"reference": "65095dac14037db0c822fb5e209e5bd3187a0303"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/fetch/zipball/46e791ff6a95864517750b9df6bbf4a17e3c9c4e",
"reference": "46e791ff6a95864517750b9df6bbf4a17e3c9c4e",
"url": "https://api.github.com/repos/utopia-php/fetch/zipball/65095dac14037db0c822fb5e209e5bd3187a0303",
"reference": "65095dac14037db0c822fb5e209e5bd3187a0303",
"shasum": ""
},
"require": {
@ -3693,9 +3693,9 @@
"description": "A simple library that provides an interface for making HTTP Requests.",
"support": {
"issues": "https://github.com/utopia-php/fetch/issues",
"source": "https://github.com/utopia-php/fetch/tree/0.4.0"
"source": "https://github.com/utopia-php/fetch/tree/0.4.1"
},
"time": "2025-03-11T21:06:56+00:00"
"time": "2025-04-14T07:34:27+00:00"
},
{
"name": "utopia-php/framework",
@ -3951,16 +3951,16 @@
},
{
"name": "utopia-php/migration",
"version": "0.8.5",
"version": "0.8.6",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "0dd95b148c581579ec05d2abbbdc13c2b4702331"
"reference": "84163e16edc0b2e64c34ad7b7c4cc5f05d762daf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/0dd95b148c581579ec05d2abbbdc13c2b4702331",
"reference": "0dd95b148c581579ec05d2abbbdc13c2b4702331",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/84163e16edc0b2e64c34ad7b7c4cc5f05d762daf",
"reference": "84163e16edc0b2e64c34ad7b7c4cc5f05d762daf",
"shasum": ""
},
"require": {
@ -4001,9 +4001,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/0.8.5"
"source": "https://github.com/utopia-php/migration/tree/0.8.6"
},
"time": "2025-04-09T05:21:09+00:00"
"time": "2025-04-14T08:22:09+00:00"
},
{
"name": "utopia-php/orchestration",

View file

@ -49,9 +49,6 @@ class Maintenance extends Action
$dbForPlatform->foreach(
'projects',
[
Query::equal('region', System::getEnv('_APP_REGION', 'default'))
],
function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) {
$queueForDeletes
->setType(DELETE_TYPE_MAINTENANCE)
@ -60,6 +57,7 @@ class Maintenance extends Action
->trigger();
},
[
Query::equal('region', [System::getEnv('_APP_REGION', 'default')]),
Query::limit(100),
]
);

View file

@ -68,7 +68,7 @@ class StatsResources extends Action
*/
$this->foreachDocument($this->dbForPlatform, 'projects', [
Query::greaterThanEqual('accessedAt', DateTime::format($last24Hours)),
Query::equal('region', System::getEnv('_APP_REGION', 'default'))
Query::equal('region', [System::getEnv('_APP_REGION', 'default')])
], function ($project) use ($queue) {
$queue
->setProject($project)

View file

@ -563,22 +563,19 @@ class Databases extends Action
$start = \microtime(true);
try {
$documents = $database->deleteDocuments($collectionId, $queries);
$count = $database->deleteDocuments(
$collectionId,
$queries,
Database::DELETE_BATCH_SIZE,
$callback
);
} catch (\Throwable $th) {
$tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : '';
Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collectionId} {$tenant} :{$th->getMessage()}");
return;
}
if (\is_callable($callback)) {
foreach ($documents as $document) {
$callback($document);
}
}
$end = \microtime(true);
$count = \count($documents);
Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds");
}

View file

@ -1050,24 +1050,20 @@ class Deletes extends Action
/**
* deleteDocuments uses a cursor, we need to add a unique order by field or use default
*/
try {
$documents = $database->deleteDocuments($collection, $queries);
$count = $database->deleteDocuments(
$collection,
$queries,
Database::DELETE_BATCH_SIZE,
$callback
);
} catch (Throwable $th) {
$tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : '';
Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collection} {$tenant} :{$th->getMessage()}");
return;
}
if (\is_callable($callback)) {
foreach ($documents as $document) {
$callback($document);
}
}
$end = \microtime(true);
$count = \count($documents);
Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds");
}