From 43e79635b92430c043fc0d174d193a1b6d3e6a08 Mon Sep 17 00:00:00 2001 From: Yaroslav Nahirnyi Date: Thu, 12 Sep 2024 17:46:57 +0300 Subject: [PATCH] fix: Fixed chunk with queue delay (#38) --- src/Mixins/EloquentBuilderMixin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Mixins/EloquentBuilderMixin.php b/src/Mixins/EloquentBuilderMixin.php index f79d40c..b314e2d 100644 --- a/src/Mixins/EloquentBuilderMixin.php +++ b/src/Mixins/EloquentBuilderMixin.php @@ -285,10 +285,14 @@ public function chunkWithQueue(): callable $builder = new SerializableBuilder($query); + $delayNumber = 1; + for ($chunkNumber = $minChunkNumber; $chunkNumber <= $maxChunkNumber; $chunkNumber++) { dispatch(new GenerateChunksJob($builder, $params, $chunkNumber)) ->onQueue($settings->queueOptions->pieceQueue) - ->delay($settings->queueOptions->delay ? $settings->queueOptions->delay * ($chunkNumber - 1) : null); + ->delay($settings->queueOptions->delay ? $settings->queueOptions->delay * ($delayNumber - 1) : null); + + $delayNumber++; } return true;