mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add platform and key counts to migration report endpoint
This commit is contained in:
@@ -713,10 +713,8 @@ Http::get('/v1/migrations/appwrite/report')
|
||||
->param('projectID', '', new Text(512), "Source's Project ID")
|
||||
->param('key', '', new Text(512), "Source's API Key")
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->action(function (array $resources, string $endpoint, string $projectID, string $key, Response $response) {
|
||||
->inject('dbForPlatform')
|
||||
->action(function (array $resources, string $endpoint, string $projectID, string $key, Response $response, Database $dbForPlatform) {
|
||||
|
||||
$appwrite = new Appwrite($projectID, $endpoint, $key);
|
||||
|
||||
@@ -735,6 +733,25 @@ Http::get('/v1/migrations/appwrite/report')
|
||||
throw new Exception(Exception::MIGRATION_PROVIDER_ERROR, 'Source Error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$sourceProject = $dbForPlatform->getDocument('projects', $projectID);
|
||||
|
||||
if (!$sourceProject->isEmpty()) {
|
||||
$projectInternalId = $sourceProject->getSequence();
|
||||
|
||||
if (\in_array(Resource::TYPE_PLATFORM, $resources)) {
|
||||
$report[Resource::TYPE_PLATFORM] = $dbForPlatform->count('platforms', [
|
||||
Query::equal('projectInternalId', [$projectInternalId]),
|
||||
]);
|
||||
}
|
||||
|
||||
if (\in_array(Resource::TYPE_KEY, $resources)) {
|
||||
$report[Resource::TYPE_KEY] = $dbForPlatform->count('keys', [
|
||||
Query::equal('resourceType', ['project']),
|
||||
Query::equal('resourceInternalId', [$projectInternalId]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_OK)
|
||||
->dynamic(new Document($report), Response::MODEL_MIGRATION_REPORT);
|
||||
|
||||
@@ -53,6 +53,18 @@ class MigrationReport extends Model
|
||||
'default' => 0,
|
||||
'example' => 20,
|
||||
])
|
||||
->addRule(Resource::TYPE_PLATFORM, [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Number of platforms to be migrated.',
|
||||
'default' => 0,
|
||||
'example' => 5,
|
||||
])
|
||||
->addRule(Resource::TYPE_KEY, [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Number of API keys to be migrated.',
|
||||
'default' => 0,
|
||||
'example' => 10,
|
||||
])
|
||||
->addRule('size', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Size of files to be migrated in mb.',
|
||||
|
||||
Reference in New Issue
Block a user