Completed
Pull Request — master (#24551)
by Thomas
19:32 queued 48s
created

Status   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 5 1
A execute() 0 8 1
1
<?php
2
3
namespace OC\Core\Command\Background\Queue;
4
5
use OCP\BackgroundJob\IJob;
6
use OCP\BackgroundJob\IJobList;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Helper\Table;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class Status extends Command {
13
14
	/** @var \OCP\BackgroundJob\IJobList */
15
	private $jobList;
16
17
	public function __construct(IJobList $jobList) {
18
		$this->jobList = $jobList;
19
		parent::__construct();
20
	}
21
22
	protected function configure() {
23
		$this
24
			->setName('background:queue:status')
25
			->setDescription('List queue status');
26
	}
27
28
	/**
29
	* @param InputInterface $input
30
	* @param OutputInterface $output
31
	 * @return void
32
	*/
33
	protected function execute(InputInterface $input, OutputInterface $output) {
34
		$t = new Table($output);
35
		$t->setHeaders(['Id', 'Job', 'Last run', 'Arguments']);
36
		$this->jobList->listJobs(function (IJob $job) use ($t) {
37
			$t->addRow([$job->getId(), \get_class($job), \date('c', $job->getLastRun()), $job->getArgument()]);
38
		});
39
		$t->render();
40
	}
41
}
42