Skip to content

Commit

Permalink
fix: Fixed chunk with queue delay (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavNahirnyi authored Sep 12, 2024
1 parent 35f9a87 commit 43e7963
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Mixins/EloquentBuilderMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 43e7963

Please sign in to comment.