From ff4e6be86a80e26bd2b15787d351f943575d95b8 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Thu, 4 Nov 2021 12:28:19 +0100 Subject: [PATCH] allow bigger chunk sizes --- src/Commands/BuildCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index e558bf1..30fde8b 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -15,7 +15,8 @@ use Illuminate\Database\Eloquent\Collection; class BuildCommand extends Command { protected $signature = 'blomstra:search:index - {--max-id= : Limits for each object the number of items to seed}'; + {--max-id= : Limits for each object the number of items to seed} + {--chunk-size= : Size of the chunks to dispatch into jobs}'; protected $description = 'Rebuilds the complete search server with its documents.'; public function handle(Container $container) @@ -80,7 +81,7 @@ class BuildCommand extends Command ->when($this->option('max-id'), function ($query, $id) { $query->where('id', '<=', $id); }) - ->chunk(50, function (Collection $collection) use ($queue, &$total, $seeder) { + ->chunk($this->option('chunk-size') ?? 1000, function (Collection $collection) use ($queue, &$total, $seeder) { $queue->pushOn(Job::$onQueue, new SavingJob($collection, $seeder)); $this->info("Pushed into the index, type: {$seeder->type()}, amount: {$collection->count()}.");