Skip to content

Commit

Permalink
Only start progress bar if any queue items
Browse files Browse the repository at this point in the history
  • Loading branch information
DieterHolvoet committed Aug 2, 2024
1 parent 0c1ceee commit 92eab9a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Commands/core/QueueCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items-
$queue->garbageCollection();
}

$this->io()->progressStart($items_limit ?: $queue->numberOfItems());
$max = $items_limit ?: $queue->numberOfItems();
if ($max > 0) {
$this->io()->progressStart($max);
}

while ((!$time_limit || $remaining > 0) && (!$items_limit || $count < $items_limit) && ($item = $queue->claimItem($lease_time))) {
try {
Expand Down Expand Up @@ -134,7 +137,9 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items-
$remaining = $end - time();
}
$elapsed = microtime(true) - $start;
$this->io()->progressFinish();
if ($max > 0) {
$this->io()->progressFinish();
}
$this->logger()->success(dt('Processed @count items from the @name queue in @elapsed sec.', ['@count' => $count, '@name' => $name, '@elapsed' => round($elapsed, 2)]));
}

Expand Down

0 comments on commit 92eab9a

Please sign in to comment.