This commit is contained in:
shimon 2025-12-07 17:03:18 +02:00
parent 4289215620
commit 8ed4fa6ff1
2 changed files with 36 additions and 37 deletions

48
composer.lock generated
View file

@ -756,16 +756,16 @@
},
{
"name": "google/protobuf",
"version": "v4.33.1",
"version": "v4.33.2",
"source": {
"type": "git",
"url": "https://github.com/protocolbuffers/protobuf-php.git",
"reference": "0cd73ccf0cd26c3e72299cce1ea6144091a57e12"
"reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/0cd73ccf0cd26c3e72299cce1ea6144091a57e12",
"reference": "0cd73ccf0cd26c3e72299cce1ea6144091a57e12",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318",
"reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318",
"shasum": ""
},
"require": {
@ -794,9 +794,9 @@
"proto"
],
"support": {
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.1"
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.2"
},
"time": "2025-11-12T21:58:05+00:00"
"time": "2025-12-05T22:12:22+00:00"
},
{
"name": "league/csv",
@ -4513,16 +4513,16 @@
},
{
"name": "utopia-php/migration",
"version": "1.3.6",
"version": "1.3.7",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "4abe70cc242bbffebfa377e4126ee2a4a1c9ef7e"
"reference": "409983bc2a9cf53a8a3dc6c23d8b1dee1950b499"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/4abe70cc242bbffebfa377e4126ee2a4a1c9ef7e",
"reference": "4abe70cc242bbffebfa377e4126ee2a4a1c9ef7e",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/409983bc2a9cf53a8a3dc6c23d8b1dee1950b499",
"reference": "409983bc2a9cf53a8a3dc6c23d8b1dee1950b499",
"shasum": ""
},
"require": {
@ -4562,9 +4562,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/1.3.6"
"source": "https://github.com/utopia-php/migration/tree/1.3.7"
},
"time": "2025-11-25T11:36:57+00:00"
"time": "2025-12-05T05:02:31+00:00"
},
{
"name": "utopia-php/mongo",
@ -5960,16 +5960,16 @@
},
{
"name": "nikic/php-parser",
"version": "v5.6.2",
"version": "v5.7.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "3a454ca033b9e06b63282ce19562e892747449bb"
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb",
"reference": "3a454ca033b9e06b63282ce19562e892747449bb",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82",
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82",
"shasum": ""
},
"require": {
@ -6012,9 +6012,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2"
"source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0"
},
"time": "2025-10-21T19:32:17+00:00"
"time": "2025-12-06T11:56:16+00:00"
},
{
"name": "phar-io/manifest",
@ -6663,16 +6663,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.30",
"version": "9.6.31",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b69489b312503bf8fa6d75a76916919d7d2fa6d4"
"reference": "945d0b7f346a084ce5549e95289962972c4272e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b69489b312503bf8fa6d75a76916919d7d2fa6d4",
"reference": "b69489b312503bf8fa6d75a76916919d7d2fa6d4",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/945d0b7f346a084ce5549e95289962972c4272e5",
"reference": "945d0b7f346a084ce5549e95289962972c4272e5",
"shasum": ""
},
"require": {
@ -6746,7 +6746,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.30"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.31"
},
"funding": [
{
@ -6770,7 +6770,7 @@
"type": "tidelift"
}
],
"time": "2025-12-01T07:35:08+00:00"
"time": "2025-12-06T07:45:52+00:00"
},
{
"name": "psr/cache",

View file

@ -7,7 +7,6 @@ use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Exception;
use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Action;
@ -159,7 +158,7 @@ abstract class ScheduleBase extends Action
foreach ($schedules as $schedule) {
$existing = $this->schedules[$schedule->getSequence()] ?? null;
$updated = strtotime($existing['resourceUpdatedAt'] ?? '0') !== strtotime($schedule->getAttribute('resourceUpdatedAt') ?? '0');
if ($existing === null || $updated) {
try {
$candidate = [
@ -186,7 +185,7 @@ abstract class ScheduleBase extends Action
Console::info("Updating: {$candidate['resourceType']}::{$candidate['resourceId']}");
$this->schedules[$schedule->getSequence()] = $candidate;
// Track projectId for updated/new schedules
$updatedProjectIds[] = $candidate['projectId'];
}
@ -201,12 +200,12 @@ abstract class ScheduleBase extends Action
// On initial load: load all projects from all schedules
if ($initialLoad) {
$projectIds = array_unique(array_map(fn($schedule) => $schedule['projectId'], $this->schedules));
$projectIds = array_unique(array_map(fn ($schedule) => $schedule['projectId'], $this->schedules));
} else {
// Only load projects for updated/new schedules
$projectIds = array_unique($updatedProjectIds);
}
// Build existing project map from schedules that already have projects loaded
$map = [];
foreach ($this->schedules as $schedule) {
@ -214,16 +213,16 @@ abstract class ScheduleBase extends Action
$map[$schedule['projectId']] = $schedule['project'];
}
}
// Only load projects that we don't already have in memory
$projectIdsToLoad = array_filter($projectIds, fn($projectId) => !isset($map[$projectId]));
$projectIdsToLoad = array_filter($projectIds, fn ($projectId) => !isset($map[$projectId]));
if (!empty($projectIdsToLoad)) {
$projectIdsToLoad = array_values($projectIdsToLoad);
$batchSize = 10_000;
$batches = array_chunk($projectIdsToLoad, $batchSize);
$projectsLoadStart = microtime(true);
foreach ($batches as $batch) {
$documents = $dbForPlatform->find('projects', [
Query::equal('$id', $batch),
@ -240,10 +239,10 @@ abstract class ScheduleBase extends Action
} else {
Console::success("No new projects to load (using " . count($map) . " cached projects)");
}
foreach ($this->schedules as $sequence => $schedule) {
$project = $map[$schedule['projectId']];
// In case the resource is blocked.
if ($isResourceBlocked($project, $collectionId, $schedule['resourceId'])) {
Console::error("Resource blocked: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
@ -256,7 +255,7 @@ abstract class ScheduleBase extends Action
unset($this->schedules[$sequence]);
continue;
}
$this->schedules[$sequence]['project'] = $project;
// In case the resource is not found (project deleted).
@ -268,7 +267,7 @@ abstract class ScheduleBase extends Action
unset($this->schedules[$sequence]);
continue;
}
if (empty($resource)) {
Console::error("Resource not found: projectId::{$schedule['projectId']} resourceId::{$schedule['resourceId']}");
unset($this->schedules[$sequence]);