diff --git a/src/Commands/core/QueueCommands.php b/src/Commands/core/QueueCommands.php index 6e0c755619..e181574378 100644 --- a/src/Commands/core/QueueCommands.php +++ b/src/Commands/core/QueueCommands.php @@ -74,6 +74,11 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items- $queue->garbageCollection(); } + $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 { // @phpstan-ignore-next-line @@ -82,6 +87,7 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items- $worker->processItem($item->data); $queue->deleteItem($item); $count++; + $this->io()->progressAdvance(); } catch (RequeueException) { // The worker requested the task to be immediately requeued. $queue->releaseItem($item); @@ -109,6 +115,9 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items- $remaining = $end - time(); } $elapsed = microtime(true) - $start; + 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)])); }