public function calculate($queue = null)
    {
        $queues = $this->queueNames(
            $supervisors = collect($this->supervisors->all()), $queue
        );

        return $queues->mapWithKeys(function ($queue) use ($supervisors) {
            $totalProcesses = $this->totalProcessesFor($supervisors, $queue);

            [$connection, $queueName] = explode(':', $queue, 2);

            $timeToClear = ! Str::contains($queueName, ',')
                ? $this->timeToClearFor($connection, $queueName)
                : collect(explode(',', $queueName))->sum(function ($queueName) use ($connection) {
                    return $this->timeToClearFor($connection, $queueName);
                });

            return $totalProcesses === 0
                    ? [$queue => round($timeToClear / 1000)]
                    : [$queue => round(($timeToClear / $totalProcesses) / 1000)];
        })->sort()->reverse()->all();
    }
public function calculate($queue = null)
    {
        $queues = $this->queueNames(
            $supervisors = collect($this->supervisors->all()), $queue
        );

        return $queues->mapWithKeys(function ($queue) use ($supervisors) {
            $totalProcesses = $this->totalProcessesFor($supervisors, $queue);

            [$connection, $queueName] = explode(':', $queue, 2);

            $timeToClear = ! Str::contains($queueName, ',')
                ? $this->timeToClearFor($connection, $queueName)
                : collect(explode(',', $queueName))->sum(function ($queueName) use ($connection) {
                    return $this->timeToClearFor($connection, $queueName);
                });

            return $totalProcesses === 0
                    ? [$queue => round($timeToClear / 1000)]
                    : [$queue => round(($timeToClear / $totalProcesses) / 1000)];
        })->sort()->reverse()->all();
    }
public function calculate ( $ queue = null ) { $ queues = $ this -> queueNames ( $ supervisors = collect ( $ this -> supervisors -> all ( ) ) , $ queue ) ; return $ queues -> mapWithKeys ( function ( $ queue ) use ( $ supervisors ) { $ totalProcesses = $ this -> totalProcessesFor ( $ supervisors , $ queue ) ; [ $ connection , $ queueName ] = explode ( ':' , $ queue , 2 ) ; $ timeToClear = ! Str :: contains ( $ queueName , ',' ) ? $ this -> timeToClearFor ( $ connection , $ queueName ) : collect ( explode ( ',' , $ queueName ) ) -> sum ( function ( $ queueName ) use ( $ connection ) { return $ this -> timeToClearFor ( $ connection , $ queueName ) ; } ) ; return $ totalProcesses === 0 ? [ $ queue => round ( $ timeToClear / 1000 ) ] : [ $ queue => round ( ( $ timeToClear / $ totalProcesses ) / 1000 ) ] ; } ) -> sort ( ) -> reverse ( ) -> all ( ) ; }
Calculate the time to clear per queue in seconds.

@param  string|null  $queue
@return array
Calculate the time to clear per queue in seconds .