@@ -16,83 +16,83 @@ |
||
| 16 | 16 | use Symfony\Component\Console\Output\OutputInterface; |
| 17 | 17 | |
| 18 | 18 | class ListCommand extends Base { |
| 19 | - public function __construct( |
|
| 20 | - protected IManager $taskProcessingManager, |
|
| 21 | - ) { |
|
| 22 | - parent::__construct(); |
|
| 23 | - } |
|
| 19 | + public function __construct( |
|
| 20 | + protected IManager $taskProcessingManager, |
|
| 21 | + ) { |
|
| 22 | + parent::__construct(); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - protected function configure() { |
|
| 26 | - $this |
|
| 27 | - ->setName('taskprocessing:task:list') |
|
| 28 | - ->setDescription('list tasks') |
|
| 29 | - ->addOption( |
|
| 30 | - 'userIdFilter', |
|
| 31 | - 'u', |
|
| 32 | - InputOption::VALUE_OPTIONAL, |
|
| 33 | - 'only get the tasks for one user ID' |
|
| 34 | - ) |
|
| 35 | - ->addOption( |
|
| 36 | - 'type', |
|
| 37 | - 't', |
|
| 38 | - InputOption::VALUE_OPTIONAL, |
|
| 39 | - 'only get the tasks for one task type' |
|
| 40 | - ) |
|
| 41 | - ->addOption( |
|
| 42 | - 'appId', |
|
| 43 | - null, |
|
| 44 | - InputOption::VALUE_OPTIONAL, |
|
| 45 | - 'only get the tasks for one app ID' |
|
| 46 | - ) |
|
| 47 | - ->addOption( |
|
| 48 | - 'customId', |
|
| 49 | - null, |
|
| 50 | - InputOption::VALUE_OPTIONAL, |
|
| 51 | - 'only get the tasks for one custom ID' |
|
| 52 | - ) |
|
| 53 | - ->addOption( |
|
| 54 | - 'status', |
|
| 55 | - 's', |
|
| 56 | - InputOption::VALUE_OPTIONAL, |
|
| 57 | - 'only get the tasks that have a specific status (STATUS_UNKNOWN=0, STATUS_SCHEDULED=1, STATUS_RUNNING=2, STATUS_SUCCESSFUL=3, STATUS_FAILED=4, STATUS_CANCELLED=5)', |
|
| 58 | - ) |
|
| 59 | - ->addOption( |
|
| 60 | - 'scheduledAfter', |
|
| 61 | - null, |
|
| 62 | - InputOption::VALUE_OPTIONAL, |
|
| 63 | - 'only get the tasks that were scheduled after a specific date (Unix timestamp)' |
|
| 64 | - ) |
|
| 65 | - ->addOption( |
|
| 66 | - 'endedBefore', |
|
| 67 | - null, |
|
| 68 | - InputOption::VALUE_OPTIONAL, |
|
| 69 | - 'only get the tasks that ended before a specific date (Unix timestamp)' |
|
| 70 | - ); |
|
| 71 | - parent::configure(); |
|
| 72 | - } |
|
| 25 | + protected function configure() { |
|
| 26 | + $this |
|
| 27 | + ->setName('taskprocessing:task:list') |
|
| 28 | + ->setDescription('list tasks') |
|
| 29 | + ->addOption( |
|
| 30 | + 'userIdFilter', |
|
| 31 | + 'u', |
|
| 32 | + InputOption::VALUE_OPTIONAL, |
|
| 33 | + 'only get the tasks for one user ID' |
|
| 34 | + ) |
|
| 35 | + ->addOption( |
|
| 36 | + 'type', |
|
| 37 | + 't', |
|
| 38 | + InputOption::VALUE_OPTIONAL, |
|
| 39 | + 'only get the tasks for one task type' |
|
| 40 | + ) |
|
| 41 | + ->addOption( |
|
| 42 | + 'appId', |
|
| 43 | + null, |
|
| 44 | + InputOption::VALUE_OPTIONAL, |
|
| 45 | + 'only get the tasks for one app ID' |
|
| 46 | + ) |
|
| 47 | + ->addOption( |
|
| 48 | + 'customId', |
|
| 49 | + null, |
|
| 50 | + InputOption::VALUE_OPTIONAL, |
|
| 51 | + 'only get the tasks for one custom ID' |
|
| 52 | + ) |
|
| 53 | + ->addOption( |
|
| 54 | + 'status', |
|
| 55 | + 's', |
|
| 56 | + InputOption::VALUE_OPTIONAL, |
|
| 57 | + 'only get the tasks that have a specific status (STATUS_UNKNOWN=0, STATUS_SCHEDULED=1, STATUS_RUNNING=2, STATUS_SUCCESSFUL=3, STATUS_FAILED=4, STATUS_CANCELLED=5)', |
|
| 58 | + ) |
|
| 59 | + ->addOption( |
|
| 60 | + 'scheduledAfter', |
|
| 61 | + null, |
|
| 62 | + InputOption::VALUE_OPTIONAL, |
|
| 63 | + 'only get the tasks that were scheduled after a specific date (Unix timestamp)' |
|
| 64 | + ) |
|
| 65 | + ->addOption( |
|
| 66 | + 'endedBefore', |
|
| 67 | + null, |
|
| 68 | + InputOption::VALUE_OPTIONAL, |
|
| 69 | + 'only get the tasks that ended before a specific date (Unix timestamp)' |
|
| 70 | + ); |
|
| 71 | + parent::configure(); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 75 | - $userIdFilter = $input->getOption('userIdFilter'); |
|
| 76 | - if ($userIdFilter === null) { |
|
| 77 | - $userIdFilter = ''; |
|
| 78 | - } elseif ($userIdFilter === '') { |
|
| 79 | - $userIdFilter = null; |
|
| 80 | - } |
|
| 81 | - $type = $input->getOption('type'); |
|
| 82 | - $appId = $input->getOption('appId'); |
|
| 83 | - $customId = $input->getOption('customId'); |
|
| 84 | - $status = $input->getOption('status') !== null ? (int)$input->getOption('status') : null; |
|
| 85 | - $scheduledAfter = $input->getOption('scheduledAfter') != null ? (int)$input->getOption('scheduledAfter') : null; |
|
| 86 | - $endedBefore = $input->getOption('endedBefore') !== null ? (int)$input->getOption('endedBefore') : null; |
|
| 74 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 75 | + $userIdFilter = $input->getOption('userIdFilter'); |
|
| 76 | + if ($userIdFilter === null) { |
|
| 77 | + $userIdFilter = ''; |
|
| 78 | + } elseif ($userIdFilter === '') { |
|
| 79 | + $userIdFilter = null; |
|
| 80 | + } |
|
| 81 | + $type = $input->getOption('type'); |
|
| 82 | + $appId = $input->getOption('appId'); |
|
| 83 | + $customId = $input->getOption('customId'); |
|
| 84 | + $status = $input->getOption('status') !== null ? (int)$input->getOption('status') : null; |
|
| 85 | + $scheduledAfter = $input->getOption('scheduledAfter') != null ? (int)$input->getOption('scheduledAfter') : null; |
|
| 86 | + $endedBefore = $input->getOption('endedBefore') !== null ? (int)$input->getOption('endedBefore') : null; |
|
| 87 | 87 | |
| 88 | - $tasks = $this->taskProcessingManager->getTasks($userIdFilter, $type, $appId, $customId, $status, $scheduledAfter, $endedBefore); |
|
| 89 | - $arrayTasks = array_map(static function (Task $task) { |
|
| 90 | - $jsonTask = $task->jsonSerialize(); |
|
| 91 | - $jsonTask['error_message'] = $task->getErrorMessage(); |
|
| 92 | - return $jsonTask; |
|
| 93 | - }, $tasks); |
|
| 88 | + $tasks = $this->taskProcessingManager->getTasks($userIdFilter, $type, $appId, $customId, $status, $scheduledAfter, $endedBefore); |
|
| 89 | + $arrayTasks = array_map(static function (Task $task) { |
|
| 90 | + $jsonTask = $task->jsonSerialize(); |
|
| 91 | + $jsonTask['error_message'] = $task->getErrorMessage(); |
|
| 92 | + return $jsonTask; |
|
| 93 | + }, $tasks); |
|
| 94 | 94 | |
| 95 | - $this->writeArrayInOutputFormat($input, $output, $arrayTasks); |
|
| 96 | - return 0; |
|
| 97 | - } |
|
| 95 | + $this->writeArrayInOutputFormat($input, $output, $arrayTasks); |
|
| 96 | + return 0; |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -81,12 +81,12 @@ |
||
| 81 | 81 | $type = $input->getOption('type'); |
| 82 | 82 | $appId = $input->getOption('appId'); |
| 83 | 83 | $customId = $input->getOption('customId'); |
| 84 | - $status = $input->getOption('status') !== null ? (int)$input->getOption('status') : null; |
|
| 85 | - $scheduledAfter = $input->getOption('scheduledAfter') != null ? (int)$input->getOption('scheduledAfter') : null; |
|
| 86 | - $endedBefore = $input->getOption('endedBefore') !== null ? (int)$input->getOption('endedBefore') : null; |
|
| 84 | + $status = $input->getOption('status') !== null ? (int) $input->getOption('status') : null; |
|
| 85 | + $scheduledAfter = $input->getOption('scheduledAfter') != null ? (int) $input->getOption('scheduledAfter') : null; |
|
| 86 | + $endedBefore = $input->getOption('endedBefore') !== null ? (int) $input->getOption('endedBefore') : null; |
|
| 87 | 87 | |
| 88 | 88 | $tasks = $this->taskProcessingManager->getTasks($userIdFilter, $type, $appId, $customId, $status, $scheduledAfter, $endedBefore); |
| 89 | - $arrayTasks = array_map(static function (Task $task) { |
|
| 89 | + $arrayTasks = array_map(static function(Task $task) { |
|
| 90 | 90 | $jsonTask = $task->jsonSerialize(); |
| 91 | 91 | $jsonTask['error_message'] = $task->getErrorMessage(); |
| 92 | 92 | return $jsonTask; |