mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add latest deployment tests
This commit is contained in:
@@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
@@ -96,6 +97,21 @@ class Delete extends Action
|
||||
}
|
||||
}
|
||||
|
||||
if ($function->getAttribute('latestDeploymentId') === $deployment->getId()) {
|
||||
$latestDeployment = $dbForProject->findOne('deployments', [
|
||||
Query::orderDesc('$createdAt'),
|
||||
]);
|
||||
$function = $dbForProject->updateDocument(
|
||||
'functions',
|
||||
$function->getId(),
|
||||
$function
|
||||
->setAttribute('latestDeploymentCreatedAt', $latestDeployment->isEmpty() ? '' : $latestDeployment->getCreatedAt())
|
||||
->setAttribute('latestDeploymentInternalId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getInternalId())
|
||||
->setAttribute('latestDeploymentId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getId())
|
||||
->setAttribute('latestDeploymentStatus', $latestDeployment->isEmpty() ? '' : $latestDeployment->getAttribute('status', ''))
|
||||
);
|
||||
}
|
||||
|
||||
if ($function->getAttribute('deploymentId') === $deployment->getId()) { // Reset function deployment
|
||||
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
||||
'deploymentId' => '',
|
||||
|
||||
@@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
@@ -96,6 +97,21 @@ class Delete extends Action
|
||||
}
|
||||
}
|
||||
|
||||
if ($site->getAttribute('latestDeploymentId') === $deployment->getId()) {
|
||||
$latestDeployment = $dbForProject->findOne('deployments', [
|
||||
Query::orderDesc('$createdAt'),
|
||||
]);
|
||||
$site = $dbForProject->updateDocument(
|
||||
'sites',
|
||||
$site->getId(),
|
||||
$site
|
||||
->setAttribute('latestDeploymentCreatedAt', $latestDeployment->isEmpty() ? '' : $latestDeployment->getCreatedAt())
|
||||
->setAttribute('latestDeploymentInternalId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getInternalId())
|
||||
->setAttribute('latestDeploymentId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getId())
|
||||
->setAttribute('latestDeploymentStatus', $latestDeployment->isEmpty() ? '' : $latestDeployment->getAttribute('status', ''))
|
||||
);
|
||||
}
|
||||
|
||||
if ($site->getAttribute('deploymentId') === $deployment->getId()) { // Reset site deployment
|
||||
$site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [
|
||||
'deploymentId' => '',
|
||||
|
||||
@@ -96,7 +96,7 @@ class Deployment extends Model
|
||||
])
|
||||
->addRule('status', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".',
|
||||
'description' => 'The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed".',
|
||||
'default' => '',
|
||||
'example' => 'ready',
|
||||
])
|
||||
|
||||
@@ -77,6 +77,24 @@ class Func extends Model
|
||||
'default' => '',
|
||||
'example' => self::TYPE_DATETIME_EXAMPLE,
|
||||
])
|
||||
->addRule('latestDeploymentId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site\'s latest deployment ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('latestDeploymentCreatedAt', [
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Latest deployment creation date in ISO 8601 format.',
|
||||
'default' => '',
|
||||
'example' => self::TYPE_DATETIME_EXAMPLE,
|
||||
])
|
||||
->addRule('latestDeploymentStatus', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed".',
|
||||
'default' => '',
|
||||
'example' => 'ready',
|
||||
])
|
||||
->addRule('scopes', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Allowed permission scopes.',
|
||||
|
||||
@@ -76,6 +76,24 @@ class Site extends Model
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('latestDeploymentId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site\'s latest deployment ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('latestDeploymentCreatedAt', [
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Latest deployment creation date in ISO 8601 format.',
|
||||
'default' => '',
|
||||
'example' => self::TYPE_DATETIME_EXAMPLE,
|
||||
])
|
||||
->addRule('latestDeploymentStatus', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed".',
|
||||
'default' => '',
|
||||
'example' => 'ready',
|
||||
])
|
||||
->addRule('vars', [
|
||||
'type' => Response::MODEL_VARIABLE,
|
||||
'description' => 'Site variables.',
|
||||
|
||||
Reference in New Issue
Block a user