Add platform and key counts to migration report endpoint

This commit is contained in:
Prem Palanisamy
2026-02-12 11:50:56 +00:00
parent 29111e5dea
commit 854a4aca82
2 changed files with 33 additions and 4 deletions
+21 -4
View File
@@ -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.',