/** * @param string $queueId * @param JobStatus $status * @return Keyspace\JobList[] */ public function jobsWithStatus($queueId, JobStatus $status) { switch (true) { case $status->equals(JobStatus::pending()): return $this->pendingJobs($queueId); case $status->equals(JobStatus::processing()): return $this->processingJobs($queueId); case $status->equals(JobStatus::successful()): return $this->successfulJobs($queueId); case $status->equals(JobStatus::failed()): return $this->failedJobs($queueId); } }
public function getPendingAction($queueId) { $jobs = $this->metro->listJobs($queueId, JobStatus::pending(), 20, 1); $responseContent = []; $responseContent['data'][] = ['type' => 'job']; return new JsonResponse($responseContent); }
private function _list(array $jobIds, JobStatus $status) { switch (true) { case $status->equals(JobStatus::pending()): $needle = 'queued'; break; case $status->equals(JobStatus::processing()): $needle = 'processing'; break; default: return $jobIds; } $list = []; foreach ($jobIds as $jobId) { if ($lastEvent = $this->keyspace->jobHistory($jobId)->lastEvent($needle)) { $timestamp = (new \DateTime($lastEvent->dateTime()))->getTimestamp(); $list[$jobId] = $timestamp; } } return $list; }
protected function execute(InputInterface $input, OutputInterface $output) { $metro = $this->metro; $id = $input->getArgument('id'); $filter = $input->getOption('filter'); if ($job = $metro->getJob($id)) { $job = $job->toArray(); $job['history'] = $metro->getHistory($id); $output->writeln($this->encode($job, $filter)); return 0; } if (in_array($id, $metro->listQueues())) { $queue = []; $queue['id'] = $id; foreach (JobStatus::all() as $status) { $queue[$status->value()] = $metro->countJobs($id, $status); } $output->writeln($this->encode($queue, $filter)); return 0; } return 1; }
protected function status() { return JobStatus::failed(); }
protected function status() { return JobStatus::successful(); }
protected function status() { return JobStatus::processing(); }
protected function status() { return JobStatus::pending(); }
function it_knows_how_many_jobs_have_succeeded(Redis $redis) { $redis->zcard('queue:my-queue:succeeded')->willReturn(5); $this->countJobs('my-queue', JobStatus::successful())->shouldReturn(5); }