Skip to content

Commit

Permalink
Update BaseBatchedJob.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker authored Apr 16, 2024
1 parent 313f2da commit 398ea65
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/queue/BaseBatchedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ final protected function totalBatches(): int
public function execute($queue): void
{
$items = $this->data()->getSlice($this->itemOffset, $this->batchSize);
$totalInBatch = is_array($items) ? count($items) : iterator_count($items);

$memoryLimit = ConfigHelper::sizeInBytes(ini_get('memory_limit'));
$startMemory = $memoryLimit != -1 ? memory_get_usage() : null;
Expand All @@ -129,9 +128,11 @@ public function execute($queue): void
$i = 0;

foreach ($items as $item) {
$this->setProgress($queue, $i / $totalInBatch, Translation::prep('app', '{step, number} of {total, number}', [
'step' => $this->itemOffset + 1,
'total' => $this->totalItems(),
$step = $this->itemOffset + 1;
$total = $this->totalItems();
$this->setProgress($queue, $step / $total, Translation::prep('app', '{step, number} of {total, number}', [
'step' => $step,
'total' => $total,
]));
$this->processItem($item);
$this->itemOffset++;
Expand Down

0 comments on commit 398ea65

Please sign in to comment.