From bd2db5e2498bf41e5ce86ca626923b3b9d6f9793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 15 Dec 2025 19:45:57 +0100 Subject: [PATCH] AI review fixes --- app/controllers/mock.php | 2 +- src/Appwrite/Platform/Workers/Deletes.php | 13 +++++++++++-- tests/e2e/Services/Sites/SitesCustomServerTest.php | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 733341968a..d129571e08 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -200,7 +200,7 @@ App::post('/v1/mock/api-key-unprefixed') }); App::post('/v1/mock/time-travels') - ->desc('Create a time-travel to chane $createdAt') + ->desc('Create a time-travel to change $createdAt') ->groups(['mock', 'api']) ->label('scope', 'public') ->label('docs', false) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 9146e8e376..40b57d4578 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -317,7 +317,7 @@ class Deletes extends Action /* @var $dbForProject Database */ $dbForProject = $getProjectDB($project); - $removalCallback = function (Document $resource) use ($dbForProject, $queueForDeletes) { + $removalCallback = function (Document $resource) use ($dbForProject, $queueForDeletes, $project) { $retention = $resource->getAttribute('deploymentRetention', 0); // 0 means unlimited - never delete @@ -327,8 +327,16 @@ class Deletes extends Action $activeDeploymentId = $resource->getAttribute('deploymentId', ''); + $resourceType = match ($resource->getCollection()) { + 'functions' => 'functions', + 'sites' => 'site', + default => null, + }; + $queries = [ Query::createdBefore(DateTime::addSeconds(new \DateTime(), -1 * $retention * 24 * 60 * 60)), + Query::equal('resourceInternalId', [$resource->getSequence()]), + Query::equal('resourceType', [$resourceType]), Query::orderDesc('$createdAt'), ]; @@ -340,10 +348,11 @@ class Deletes extends Action 'deployments', $queries, $dbForProject, - function (Document $deployment) use ($queueForDeletes) { + function (Document $deployment) use ($queueForDeletes, $project) { $queueForDeletes ->setType(DELETE_TYPE_DOCUMENT) ->setDocument($deployment) + ->setProject($project) ->trigger(); } ); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 05b259a9ae..eb0900ed5e 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -3090,7 +3090,7 @@ class SitesCustomServerTest extends Scope ]); $this->assertSame(201, $response['headers']['status-code']); $this->assertSame(0, $response['body']['deploymentRetention']); - $siteId[] = $response['body']['$id']; + $siteIds[] = $response['body']['$id']; $response = $this->getSite($response['body']['$id']); $this->assertSame(200, $response['headers']['status-code']); @@ -3106,7 +3106,7 @@ class SitesCustomServerTest extends Scope ]); $this->assertSame(201, $response['headers']['status-code']); $this->assertSame(0, $response['body']['deploymentRetention']); - $siteId[] = $response['body']['$id']; + $siteIds[] = $response['body']['$id']; $response = $this->getSite($response['body']['$id']); $this->assertSame(200, $response['headers']['status-code']); @@ -3121,7 +3121,7 @@ class SitesCustomServerTest extends Scope ]); $this->assertSame(201, $response['headers']['status-code']); $this->assertSame(180, $response['body']['deploymentRetention']); - $siteId[] = $response['body']['$id']; + $siteIds[] = $response['body']['$id']; $response = $this->getSite($response['body']['$id']); $this->assertSame(200, $response['headers']['status-code']); @@ -3156,7 +3156,7 @@ class SitesCustomServerTest extends Scope ]); $this->assertSame(201, $response['headers']['status-code']); $this->assertSame(180, $response['body']['deploymentRetention']); - $siteId[] = $response['body']['$id']; + $siteIds[] = $response['body']['$id']; $siteIdToUpdate = $response['body']['$id']; $response = $this->updateSite([