From de4c092c2774e5694c5189be33aa00f8ab743517 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 6 Aug 2024 11:48:07 +0300 Subject: [PATCH] getBatchSize --- src/Migration/Destination.php | 3 --- src/Migration/Destinations/Appwrite.php | 5 ----- src/Migration/Source.php | 15 +++++++++------ src/Migration/Sources/Appwrite.php | 7 ++++++- src/Migration/Target.php | 5 ----- src/Migration/Transfer.php | 3 --- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Migration/Destination.php b/src/Migration/Destination.php index 3c1146e..39d1b39 100644 --- a/src/Migration/Destination.php +++ b/src/Migration/Destination.php @@ -27,13 +27,11 @@ public function setSource(Source $source): self * @param array $resources Resources to transfer * @param callable $callback Callback to run after transfer * @param string $rootResourceId Root resource ID, If enabled you can only transfer a single root resource - * @param int $batchSize The number of resources to transfer in a single batch */ public function run( array $resources, callable $callback, string $rootResourceId = '', - int $batchSize = 100, ): void { $this->source->run( $resources, @@ -41,7 +39,6 @@ function (array $resources) use ($callback) { $this->import($resources, $callback); }, $rootResourceId, - $batchSize ); } diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 8c81131..8a474c9 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -1340,9 +1340,4 @@ private function importDeployment(Deployment $deployment): Resource return $deployment; } - - public function getBatchSize(): int - { - return 200; - } } diff --git a/src/Migration/Source.php b/src/Migration/Source.php index 6bd38c2..7841761 100644 --- a/src/Migration/Source.php +++ b/src/Migration/Source.php @@ -27,7 +27,7 @@ public function callback(array $resources): void * @param callable $callback Callback to run after transfer * @param string $rootResourceId Root resource ID, If enabled you can only transfer a single root resource */ - public function run(array $resources, callable $callback, string $rootResourceId = '', int $batchSize = 100): void + public function run(array $resources, callable $callback, string $rootResourceId = ''): void { $this->rootResourceId = $rootResourceId; @@ -46,21 +46,20 @@ public function run(array $resources, callable $callback, string $rootResourceId $this->cache->addAll($prunedResources); }; - $batchSize = $this->getBatchSize(); - - $this->exportResources($resources, $batchSize); + $this->exportResources($resources); } /** * Export Resources * * @param array $resources Resources to export - * @param int $batchSize Max 100 */ - public function exportResources(array $resources, int $batchSize): void + public function exportResources(array $resources): void { // Convert Resources back into their relevant groups + $batchSize = $this->getBatchSize(); + $groups = []; foreach ($resources as $resource) { if (\in_array($resource, Transfer::GROUP_AUTH_RESOURCES)) { @@ -96,6 +95,10 @@ public function exportResources(array $resources, int $batchSize): void } } } + public function getBatchSize(): int + { + return 100; + } /** * Export Auth Group diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index e3e34c0..8277dfb 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -1468,4 +1468,9 @@ private function exportDeploymentData(Func $func, array $deployment): void } } } -} + + public function getBatchSize(): int + { + return 250; + } +} \ No newline at end of file diff --git a/src/Migration/Target.php b/src/Migration/Target.php index e4f0140..a8165c2 100644 --- a/src/Migration/Target.php +++ b/src/Migration/Target.php @@ -225,9 +225,4 @@ public function addWarning(Warning $warning): void public function shutdown(): void { } - - public function getBatchSize(): int - { - return 100; - } } diff --git a/src/Migration/Transfer.php b/src/Migration/Transfer.php index ce5f0ec..af460b0 100644 --- a/src/Migration/Transfer.php +++ b/src/Migration/Transfer.php @@ -181,14 +181,12 @@ public function getStatusCounters(): array * @param array $resources Resources to transfer * @param callable $callback Callback to run after transfer * @param string|null $rootResourceId Root resource ID, If enabled you can only transfer a single root resource - * @param int $batchSize * @throws \Exception */ public function run( array $resources, callable $callback, string $rootResourceId = null, - int $batchSize = 100 ): void { // Allows you to push entire groups if you want. $computedResources = []; @@ -217,7 +215,6 @@ public function run( $computedResources, $callback, $rootResourceId, - $batchSize ); }