From d137b41c0b970d033aa5722e08d55ed2d3e7f72e Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 1 May 2025 11:22:19 +0530 Subject: [PATCH] add: expose source report for cloud. --- src/Appwrite/Platform/Workers/Migrations.php | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 4939dc8143..db156d7798 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -34,6 +34,13 @@ class Migrations extends Action protected Document $project; + /** + * Accessed on cloud for telemetry. + * + * @type array + */ + private array $sourceReport = []; + /** * @var callable */ @@ -101,7 +108,7 @@ class Migrations extends Action $source = $migration->getAttribute('source'); $credentials = $migration->getAttribute('credentials'); - return match ($source) { + $migrationSource = match ($source) { Firebase::getName() => new Firebase( json_decode($credentials['serviceAccount'], true), ), @@ -130,6 +137,10 @@ class Migrations extends Action ), default => throw new \Exception('Invalid source type'), }; + + $this->sourceReport = $migrationSource->report(); + + return $migrationSource; } /** @@ -381,4 +392,16 @@ class Migrations extends Action } } } + + /** + * Returns a report of resources in the source. + * + * Should be called after `processSource()` to ensure the data is populated. + * + * @return array Resource type mapped to their counts. + */ + protected function getSourceReport(): array + { + return $this->sourceReport; + } }