Returns the percentage, current and total number of
        jobs in the queue.
422395
def progress(self):
        
        total = len(self.all_jobs)
        remaining = total - len(self.active_jobs) if total > 0 else 0
        percent = int(100 * (float(remaining) / total)) if total > 0 else 0
        return percent
113308
def tracked(self):
        ''''''
        results = json.loads(self.client('track'))
        results['jobs'] = [Job(self, **job) for job in results['jobs']]
        return results
1223745
@VisibleForTesting
    public int getCurrentTaskCount() {
        synchronized (this.queue) {
            int size = this.queue.size() + this.filterQueue.size();
            if (size > 0) {
                // Some tasks may have completed, but we haven't yet been able to clean them up.
                size -= this.queue.values().stream().filter(CompletableFuture::isDone).count();
                size -= this.filterQueue.values().stream().filter(CompletableFuture::isDone).count();
            }

            return size;
        }
    }
594962
def _calculate_num_queries(self):
        
        request_totals = self._totals("request")
        response_totals = self._totals("response")

        return request_totals[2] + response_totals[2]
20201
@Override
    public long getCumulativeJobInstancesCount()
    {
        DbConn em2 = Helpers.getNewDbSession();
        try
        {
            return em2.runSelectSingle("history_select_count_for_poller", Long.class, this.queue.getId(), this.engine.getNode().getId());
        }
        finally
        {
            Helpers.closeQuietly(em2);
        }
    }
16183
def get_jobs_to_queue(self, with_times=False):
        
        return self.get_jobs(to_unix(datetime.utcnow()), with_times=with_times)
1305710
def count(self):
		
		result = 0
		for tasks in self.__registry.values():
			result += len(tasks)
		return result
620484
public function getAvailableJobsForQueueCount($jobQueue)
    {
        $result = $this->_em->createQuery('SELECT j.queue FROM JMSJobQueueBundle:Job j WHERE j.state IN (:availableStates) AND j.queue = :queue')
            ->setParameter('availableStates', [Job::STATE_RUNNING, Job::STATE_NEW, Job::STATE_PENDING])
            ->setParameter('queue', $jobQueue)
            ->setMaxResults(1)
            ->getOneOrNullResult();

        return \count($result);
    }
802417
public function getStats()
    {
        $result = [
            self::STATS_QUEUES_LIST   => [],
            self::STATS_JOBS_TOTAL    => 0,
            self::STATS_JOBS_READY    => 0,
            self::STATS_JOBS_RESERVED => 0,
            self::STATS_JOBS_DELAYED  => 0,
            self::STATS_JOBS_BURIED   => 0,
        ];

        $queueList = $this->getQueueNames();
        if (count($queueList) == 0) {
            return $result;
        }

        $result[self::STATS_QUEUES_LIST] = $queueList;

        foreach ($queueList as $queueName) {
            $itemStats = $this->getQueueInfo($queueName);
            $result[self::STATS_JOBS_READY] += $itemStats[self::STATS_JOBS_READY];
            $result[self::STATS_JOBS_RESERVED] += $itemStats[self::STATS_JOBS_RESERVED];
            $result[self::STATS_JOBS_DELAYED] += $itemStats[self::STATS_JOBS_DELAYED];
            $result[self::STATS_JOBS_BURIED] += $itemStats[self::STATS_JOBS_BURIED];
            $result[self::STATS_JOBS_TOTAL] += $itemStats[self::STATS_JOBS_TOTAL];
            $result[self::STATS_QUEUES][$queueName] = $itemStats;
        }

        return $result;
    }
720209
public static function status($queue = "default") {
        $rs = self::runQuery("
            SELECT COUNT(*) as total, COUNT(failed_at) as failed, COUNT(locked_at) as locked
            FROM `" . self::$jobsTable . "`
            WHERE queue = ?
        ", array($queue));
        $rs = $rs[0];

        $failed = $rs["failed"];
        $locked = $rs["locked"];
        $total  = $rs["total"];
        $outstanding = $total - $locked - $failed;

        return array(
            "outstanding" => $outstanding,
            "locked" => $locked,
            "failed" => $failed,
            "total"  => $total
        );
    }
93534
public int getProgressPercentage()  {
        // Implemented using node counts...
        if (isRunning()) {
            int progress = (hProcess.getTestCurrentCount(plugin) * 100) / hProcess.getTestTotalCount();
            // Make sure not return 100 (or more) if still running...
            // That might happen if more nodes are being scanned that the ones enumerated at the beginning.
            return progress >= 100 ? 99 : progress;
        } else if (isCompleted() || isSkipped()) {
            return 100;        
            
        } else {
            return 0;
        }
    }
527952
public function stats() {
		$this->out('Jobs currently in the queue:');

		$types = $this->QueuedJobs->getTypes()->toArray();
		foreach ($types as $type) {
			$this->out('      ' . str_pad($type, 20, ' ', STR_PAD_RIGHT) . ': ' . $this->QueuedJobs->getLength($type));
		}
		$this->hr();
		$this->out('Total unfinished jobs: ' . $this->QueuedJobs->getLength());
		$this->out('Running workers (processes): ' . $this->QueueProcesses->findActive()->count());
		$this->out('Server name: ' . $this->QueueProcesses->buildServerString());
		$this->hr();
		$this->out('Finished job statistics:');
		$data = $this->QueuedJobs->getStats();
		foreach ($data as $item) {
			$this->out(' ' . $item['job_type'] . ': ');
			$this->out('   Finished Jobs in Database: ' . $item['num']);
			$this->out('   Average Job existence    : ' . str_pad(Number::precision($item['alltime']), 8, ' ', STR_PAD_LEFT) . 's');
			$this->out('   Average Execution delay  : ' . str_pad(Number::precision($item['fetchdelay']), 8, ' ', STR_PAD_LEFT) . 's');
			$this->out('   Average Execution time   : ' . str_pad(Number::precision($item['runtime']), 8, ' ', STR_PAD_LEFT) . 's');
		}
	}
1091296
def progress(self, *restrictions, display=True):
        
        todo = self._jobs_to_do(restrictions)
        total = len(todo)
        remaining = len(todo - self.target)
        if display:
            print('%-20s' % self.__class__.__name__,
                  'Completed %d of %d (%2.1f%%)   %s' % (
                      total - remaining, total, 100 - 100 * remaining / (total+1e-12),
                      datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')), flush=True)
        return remaining, total
1315486
def info(self):
        
        url = "queues/%s" % (self.name,)
        result = self.client.get(url)

        return result['body']['queue']
88223
public long getTaskCount() {
        final ReentrantLock mainLock = this.mainLock;
        mainLock.lock();
        try {
            long n = completedTaskCount;
            for (Worker w : workers) {
                n += w.completedTasks;
                if (w.isLocked())
                    ++n;
            }
            return n + workQueue.size();
        } finally {
            mainLock.unlock();
        }
    }
1058303
def get_percentage(self):
        
        cumulative_elapsed_time = self.get_cumulative_elapsed_time()
        sum_elapsed_time = sum(cumulative_elapsed_time, datetime.timedelta())
        if not sum_elapsed_time:
            raise ValueError("cannot get percentage if there is no any elapsed time")
        return [div_timedelta(t, sum_elapsed_time) for t in cumulative_elapsed_time]
11839
public function stats()
    {
        $ResqueStatus = $this->ResqueStatus;

        $workers = CakeResque::getWorkers();

        // List of all queues
        $queues = array_unique(CakeResque::getQueues());

        // List of queues monitored by a worker
        $activeQueues = [];
        foreach ($workers as $worker) {
            $workerParams = explode(':', $worker);
            $activeQueues = array_merge($activeQueues, explode(',', array_pop($workerParams)));
        }

        $this->out("\n");
        $this->out('<info>' . __d('cake_resque', 'Resque Statistics') . '</info>');
        $this->hr();
        $this->out("\n");

        $this->out('<info>' . __d('cake_resque', 'Jobs Stats') . '</info>');
        $this->out('   ' . __d('cake_resque', 'Processed Jobs : {0}', number_format(Resque_Stat::get('processed'))));
        $this->out('   <warning>' . __d('cake_resque', 'Failed Jobs    : {0}', number_format(Resque_Stat::get('failed'))) . '</warning>');

        if (Configure::read('CakeResque.Scheduler.enabled') === true) {
            $this->out('   ' . __d('cake_resque', 'Scheduled Jobs : {0}', number_format(Stat::get())));
        }

        $this->out("\n");

        $count = [];
        $this->out('<info>' . __d('cake_resque', 'Queues Stats') . '</info>');
        for ($i = count($queues) - 1; $i >= 0; --$i) {
            $count[ $queues[ $i ] ] = CakeResque::getQueueSize($queues[ $i ]);
            if (!in_array($queues[ $i ], $activeQueues) && $count[ $queues[ $i ] ] == 0) {
                unset($queues[ $i ]);
            }
        }

        $this->out('   ' . __d('cake_resque', 'Queues count : {0}', count($queues)));
        foreach ($queues as $queue) {
            $this->out(sprintf("\t- %-15s : %12s %s", $queue, number_format($count[ $queue ]), __dn('cake_resque', 'pending job', 'pending jobs', $count[ $queue ]) . (!in_array($queue, $activeQueues) ? " <error>(unmonitored queue)</error>" : '')));
        }

        $this->out("\n");
        $this->out('<info>' . __d('cake_resque', 'Workers Stats') . '</info>');
        $this->out('   ' . __d('cake_resque', 'Workers count : {0}', count($workers)));

        $pausedWorkers = $ResqueStatus->getPausedWorker();
        $schedulerWorkers = [];

        if (!empty($workers)) {
            $this->out("\t<info>" . strtoupper(__d('cake_resque', 'regular workers')) . "</info>");
            foreach ($workers as $worker) {
                if (Configure::read('CakeResque.Scheduler.enabled') === true && $ResqueStatus->isSchedulerWorker($worker)) {
                    $schedulerWorkers[] = $worker;
                    continue;
                }
                $this->out("\t* <bold>" . (string)$worker . '</bold>' . (in_array((string)$worker, $pausedWorkers) ? ' <warning>(' . __d('cake_resque', 'paused') . ')</warning>' : ''));
                $this->out("\t   - " . __d('cake_resque', 'Started on') . "     : " . CakeResque::getWorkerStartDate($worker));
                $this->out("\t   - " . __d('cake_resque', 'Processed Jobs') . " : " . $worker->getStat('processed'));
                $worker->getStat('failed') == 0
                    ? $this->out("\t   - " . __d('cake_resque', 'Failed Jobs') . "    : " . $worker->getStat('failed'))
                    : $this->out("\t   - <warning>" . __d('cake_resque', 'Failed Jobs') . "    : " . $worker->getStat('failed') . "</warning>");
            }
        }

        $this->out("\n");

        if (!empty($schedulerWorkers)) {
            $this->out("\t<info>" . strtoupper(__d('cake_resque', 'scheduler worker')) . "</info>" . (in_array((string)$schedulerWorkers[0], $pausedWorkers) ? ' <warning>(' . __d('cake_resque', 'paused') . ')</warning>' : ''));
            foreach ($schedulerWorkers as $worker) {
                $schedulerWorker = new ResqueScheduler();
                $delayedJobCount = $schedulerWorker->getDelayedQueueScheduleSize();
                $this->out("\t   - " . __d('cake_resque', 'Started on') . "     : " . CakeResque::getWorkerStartDate($worker));
                $this->out("\t   - " . __d('cake_resque', 'Delayed Jobs') . "   : " . $delayedJobCount);

                if ($delayedJobCount > 0) {
                    $this->out("\t   - " . __d('cake_resque', 'Next Job on') . "    : " . strftime('%a %b %d %H:%M:%S %Z %Y', $schedulerWorker->nextDelayedTimestamp()));
                }
            }
            $this->out("\n");
        } elseif (Configure::read('CakeResque.Scheduler.enabled') === true) {
            $jobsCount = ResqueScheduler::getDelayedQueueScheduleSize();
            if ($jobsCount > 0) {
                $this->out("\t<error>************ " . __d('cake_resque', 'Alert') . " ************</error>");
                $this->out("\t<bold>" . __d('cake_resque', 'The Scheduler Worker is not running') . "</bold>");
                $this->out("\t" . __d('cake_resque', 'But there is still <bold>{0}</bold> scheduled jobs left in its queue', $jobsCount));
                $this->out("\t<error>********************************</error>");
                $this->out("\n");
            }
        }
    }