From 14cf5b03caa985474b1c8edc7fef2ce1627528d7 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 1 Oct 2024 17:20:59 +0200 Subject: feat(taskprocessing): new command to get a task from a task ID, include error_message in list and get commands Signed-off-by: Julien Veyssier --- core/Command/TaskProcessing/GetCommand.php | 41 +++++++++++++++++++++++++++++ core/Command/TaskProcessing/ListCommand.php | 6 ++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 core/Command/TaskProcessing/GetCommand.php (limited to 'core/Command/TaskProcessing') diff --git a/core/Command/TaskProcessing/GetCommand.php b/core/Command/TaskProcessing/GetCommand.php new file mode 100644 index 00000000000..a61ddbe1621 --- /dev/null +++ b/core/Command/TaskProcessing/GetCommand.php @@ -0,0 +1,41 @@ +setName('taskprocessing:task:get') + ->setDescription('Display all information for a specific task') + ->addArgument( + 'task-id', + InputArgument::REQUIRED, + 'ID of the task to display' + ); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $taskId = (int)$input->getArgument('task-id'); + $task = $this->taskProcessingManager->getTask($taskId); + $jsonTask = $task->jsonSerialize(); + $jsonTask['error_message'] = $task->getErrorMessage(); + $this->writeArrayInOutputFormat($input, $output, $jsonTask); + return 0; + } +} diff --git a/core/Command/TaskProcessing/ListCommand.php b/core/Command/TaskProcessing/ListCommand.php index 46f32e0bc53..f4ea76729d9 100644 --- a/core/Command/TaskProcessing/ListCommand.php +++ b/core/Command/TaskProcessing/ListCommand.php @@ -83,7 +83,11 @@ class ListCommand extends Base { $endedBefore = $input->getOption('endedBefore'); $tasks = $this->taskProcessingManager->getTasks($userIdFilter, $type, $appId, $customId, $status, $scheduledAfter, $endedBefore); - $arrayTasks = array_map(fn (Task $task): array => $task->jsonSerialize(), $tasks); + $arrayTasks = array_map(static function (Task $task) { + $jsonTask = $task->jsonSerialize(); + $jsonTask['error_message'] = $task->getErrorMessage(); + return $jsonTask; + }, $tasks); $this->writeArrayInOutputFormat($input, $output, $arrayTasks); return 0; -- cgit v1.2.3