Batch Jobs: how to know you're in last batch? #13878
-
I'm working on a plugin that uses the new batched queue jobs that were added in 4.4 and I'm looking for a way to execute a finishing step outside the my batched query when all data has been processed. Should I try to calculate this myself (by getting a count of the items in my query and the slices in the batch maybe?) or is there a recommended way to go about this? |
Beta Was this translation helpful? Give feedback.
Answered by
brandonkelly
Nov 4, 2023
Replies: 1 comment 1 reply
-
You could do this by overriding the public function execute($queue): void
{
parent::execute($queue);
// Was this the last batch?
if ($this->itemOffset >= $this->totalItems()) {
// ...
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
brandonkelly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do this by overriding the
execute()
function like so: