@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | // do dummy stuff... |
| 13 | 13 | $duration = ceil($this->getParameter('duration', 3)); |
| 14 | - for ($i=0; $i<$duration; $i++) { |
|
| 14 | + for ($i = 0; $i < $duration; $i++) { |
|
| 15 | 15 | $this->setTaskProgress($i / $duration); |
| 16 | 16 | sleep(1); |
| 17 | 17 | } |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | $this |
| 25 | 25 | ->setName('task:edit') |
| 26 | 26 | ->setDescription('Edit a Task') |
| 27 | - ->addArgument('id', InputArgument::REQUIRED, 'Task Id') |
|
| 27 | + ->addArgument('id', InputArgument::REQUIRED, 'Task Id') |
|
| 28 | 28 | ->addOption('parent-id', 'i', InputOption::VALUE_OPTIONAL, 'Set parent Id (Eg. 123)', null) |
| 29 | - ->addOption('profile', 'p', InputOption::VALUE_OPTIONAL, 'Set profile (eg. "high-cpu")', null) |
|
| 30 | - ->addOption('status', 's', InputOption::VALUE_OPTIONAL, 'Set status (pending|waiting|running|success|failed|finished)', null) |
|
| 29 | + ->addOption('profile', 'p', InputOption::VALUE_OPTIONAL, 'Set profile (eg. "high-cpu")', null) |
|
| 30 | + ->addOption('status', 's', InputOption::VALUE_OPTIONAL, 'Set status (pending|waiting|running|success|failed|finished)', null) |
|
| 31 | 31 | ; |
| 32 | 32 | |
| 33 | 33 | parent::configure(); |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $table = new OutputTable; |
| 74 | - $table->addColumn('Key', 15, OutputTable::RIGHT); |
|
| 75 | - $table->addColumn('Value', 25, OutputTable::LEFT); |
|
| 74 | + $table->addColumn('Key', 15, OutputTable::RIGHT); |
|
| 75 | + $table->addColumn('Value', 25, OutputTable::LEFT); |
|
| 76 | 76 | |
| 77 | 77 | $table->addRow([ |
| 78 | 78 | 'Key' => 'Id', |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | $this |
| 26 | 26 | ->setName('task:add') |
| 27 | 27 | ->setDescription('Add a Task') |
| 28 | - ->addArgument('name', InputArgument::REQUIRED, 'Name of the Task') |
|
| 29 | - ->addArgument('profile', InputArgument::REQUIRED, 'Profile of the Task') |
|
| 30 | - ->addArgument('job', InputArgument::REQUIRED, 'Job class namespace') |
|
| 28 | + ->addArgument('name', InputArgument::REQUIRED, 'Name of the Task') |
|
| 29 | + ->addArgument('profile', InputArgument::REQUIRED, 'Profile of the Task') |
|
| 30 | + ->addArgument('job', InputArgument::REQUIRED, 'Job class namespace') |
|
| 31 | 31 | ->addOption('parent-id', 'i', InputOption::VALUE_OPTIONAL, 'Set parent Id (Eg. 123)', null) |
| 32 | - ->addOption('status', 's', InputOption::VALUE_REQUIRED, 'Set status (Eg. waiting)', Task::STATUS_PENDING) |
|
| 32 | + ->addOption('status', 's', InputOption::VALUE_REQUIRED, 'Set status (Eg. waiting)', Task::STATUS_PENDING) |
|
| 33 | 33 | ->addOption('parameter', 'p', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Add a parameter (Eg. --parameter="bitrate: 1024")', []) |
| 34 | 34 | ; |
| 35 | 35 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | $this |
| 26 | 26 | ->setName('queue:show') |
| 27 | 27 | ->setDescription('List tasks from the queue') |
| 28 | - ->addOption('profile', 'p', InputOption::VALUE_OPTIONAL, 'Filter by profile (eg. "high-cpu")', null) |
|
| 29 | - ->addOption('status', 's', InputOption::VALUE_OPTIONAL, 'Filter by status (pending|waiting|running|success|failed|finished)', null) |
|
| 28 | + ->addOption('profile', 'p', InputOption::VALUE_OPTIONAL, 'Filter by profile (eg. "high-cpu")', null) |
|
| 29 | + ->addOption('status', 's', InputOption::VALUE_OPTIONAL, 'Filter by status (pending|waiting|running|success|failed|finished)', null) |
|
| 30 | 30 | ->addOption('sort-order', 'o', InputOption::VALUE_OPTIONAL, 'Sort by order asc|desc', 'asc') |
| 31 | - ->addOption('follow', 'f', InputOption::VALUE_NONE, 'Refresh screen, display Queue Tasks in real time') |
|
| 31 | + ->addOption('follow', 'f', InputOption::VALUE_NONE, 'Refresh screen, display Queue Tasks in real time') |
|
| 32 | 32 | ; |
| 33 | 33 | |
| 34 | 34 | } |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if ($count) { |
| 89 | 89 | $table = new OutputTable; |
| 90 | - $table->addColumn('Id', 5, OutputTable::RIGHT); |
|
| 91 | - $table->addColumn('Parent', 5, OutputTable::RIGHT); |
|
| 90 | + $table->addColumn('Id', 5, OutputTable::RIGHT); |
|
| 91 | + $table->addColumn('Parent', 5, OutputTable::RIGHT); |
|
| 92 | 92 | $table->addColumn('Profile', 10, OutputTable::RIGHT); |
| 93 | - $table->addColumn('Name', 14, OutputTable::LEFT); |
|
| 94 | - $table->addColumn('Worker', 20, OutputTable::LEFT); |
|
| 95 | - $table->addColumn('Status', 8, OutputTable::LEFT); |
|
| 96 | - $table->addColumn('%', 4, OutputTable::RIGHT); |
|
| 93 | + $table->addColumn('Name', 14, OutputTable::LEFT); |
|
| 94 | + $table->addColumn('Worker', 20, OutputTable::LEFT); |
|
| 95 | + $table->addColumn('Status', 8, OutputTable::LEFT); |
|
| 96 | + $table->addColumn('%', 4, OutputTable::RIGHT); |
|
| 97 | 97 | |
| 98 | 98 | foreach ($tasks as $task) { /* @var $task \Libcast\JobQueue\Task */ |
| 99 | 99 | $table->addRow([ |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | ], $task->getStatus()); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $output->getFormatter()->setStyle('pending', new OutputFormatterStyle('white')); |
|
| 111 | - $output->getFormatter()->setStyle('waiting', new OutputFormatterStyle('blue')); |
|
| 112 | - $output->getFormatter()->setStyle('running', new OutputFormatterStyle('blue', 'cyan')); |
|
| 113 | - $output->getFormatter()->setStyle('failed', new OutputFormatterStyle('red')); |
|
| 114 | - $output->getFormatter()->setStyle('success', new OutputFormatterStyle('green')); |
|
| 110 | + $output->getFormatter()->setStyle('pending', new OutputFormatterStyle('white')); |
|
| 111 | + $output->getFormatter()->setStyle('waiting', new OutputFormatterStyle('blue')); |
|
| 112 | + $output->getFormatter()->setStyle('running', new OutputFormatterStyle('blue', 'cyan')); |
|
| 113 | + $output->getFormatter()->setStyle('failed', new OutputFormatterStyle('red')); |
|
| 114 | + $output->getFormatter()->setStyle('success', new OutputFormatterStyle('green')); |
|
| 115 | 115 | $output->getFormatter()->setStyle('finished', new OutputFormatterStyle('green', null, ['bold'])); |
| 116 | 116 | |
| 117 | 117 | $this->addLine($table->getTable(true)); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | protected function countColumns() |
| 39 | 39 | { |
| 40 | - return count($this->columns); |
|
| 40 | + return count($this->columns); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function addRow(array $cells, $style = null) |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $strings[] = $this->getRow($i, $with_style); |
| 98 | 98 | |
| 99 | 99 | if ($i < 0) { |
| 100 | - $strings[] = $this->getLine(); |
|
| 100 | + $strings[] = $this->getLine(); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function getRowStyle($i) |
| 146 | 146 | { |
| 147 | 147 | if (!isset($this->row_style[$i]) || $this->row_style[$i] === '#') { |
| 148 | - return null; |
|
| 148 | + return null; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $this->row_style[$i]; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function getCell($column, $row) |
| 155 | 155 | { |
| 156 | 156 | if (!isset($this->rows[$row][$column])) { |
| 157 | - throw new CommandException("Their is no value for column '$column', row '$row'"); |
|
| 157 | + throw new CommandException("Their is no value for column '$column', row '$row'"); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | return $this->rows[$row][$column]; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $count = 0; |
| 166 | 166 | |
| 167 | 167 | foreach ($this->getColumnTitles() as $title) { |
| 168 | - $count += $this->getColumnWidth($title); |
|
| 168 | + $count += $this->getColumnWidth($title); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $count += $this->countColumns() * 3; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function setLoggerWorker(Worker $worker) |
| 46 | 46 | { |
| 47 | - $this->logger->pushProcessor(function ($record) use ($worker) { |
|
| 47 | + $this->logger->pushProcessor(function($record) use ($worker) { |
|
| 48 | 48 | $record['context']['tags']['worker_profile'] = $worker->getProfile(); |
| 49 | 49 | $record['context']['tags']['worker_name'] = $worker->getName(); |
| 50 | 50 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setLoggerTask(Task $task) |
| 60 | 60 | { |
| 61 | - $this->logger->pushProcessor(function ($record) use ($task) { |
|
| 61 | + $this->logger->pushProcessor(function($record) use ($task) { |
|
| 62 | 62 | $record['context']['tags']['task_id'] = $task->getId(); |
| 63 | 63 | $record['context']['tags']['task_name'] = $task->getName(); |
| 64 | 64 | |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | foreach ($competitor_ids as $rank => $id) { |
| 80 | 80 | // Collect ancestor id if exists |
| 81 | 81 | $competitor_id = ($competitor = $this->getTask($id)) ? |
| 82 | - $competitor->getRootId() : |
|
| 83 | - $id; |
|
| 82 | + $competitor->getRootId() : $id; |
|
| 84 | 83 | |
| 85 | 84 | // Avoid having two competitors with the same root ancestor |
| 86 | 85 | if (in_array($competitor_id, $competitor_roots)) { |
@@ -344,8 +343,8 @@ discard block |
||
| 344 | 343 | $keys = $this->getClient()->keys(self::key('tasks:*:*')); |
| 345 | 344 | |
| 346 | 345 | // Hide `finished` Tasks when listing everything |
| 347 | - $keys = array_filter($keys, function ($value) { |
|
| 348 | - return !preg_match('/^'. self::PREFIX . ':tasks:([^:]+):' . Task::STATUS_FINISHED . '$/', $value); |
|
| 346 | + $keys = array_filter($keys, function($value) { |
|
| 347 | + return !preg_match('/^' . self::PREFIX . ':tasks:([^:]+):' . Task::STATUS_FINISHED . '$/', $value); |
|
| 349 | 348 | }); |
| 350 | 349 | } elseif (!$filter_by_profile) { |
| 351 | 350 | $keys = $this->getClient()->keys(self::key("tasks:*:$filter_by_status")); |
@@ -447,10 +447,12 @@ |
||
| 447 | 447 | |
| 448 | 448 | // recursively add children's progressions |
| 449 | 449 | $progress = $task->getProgress(); |
| 450 | - foreach ($task->getChildren() as $child) /* @var $child Task */ |
|
| 450 | + foreach ($task->getChildren() as $child) { |
|
| 451 | + /* @var $child Task */ |
|
| 451 | 452 | { |
| 452 | 453 | $progress += $this->getProgress($child, false); |
| 453 | 454 | } |
| 455 | + } |
|
| 454 | 456 | |
| 455 | 457 | $global = $progress / ($task->countChildren() + 1); |
| 456 | 458 | |