aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-10-01 17:20:59 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-10-01 20:30:31 +0200
commit14cf5b03caa985474b1c8edc7fef2ce1627528d7 (patch)
tree359fe5605bda5d2b5e621bc3334a27280b9b9a0f /core/Command
parent26762172f5697febc7971a0bf5ac83d7a4c3cf35 (diff)
downloadnextcloud-server-14cf5b03caa985474b1c8edc7fef2ce1627528d7.tar.gz
nextcloud-server-14cf5b03caa985474b1c8edc7fef2ce1627528d7.zip
feat(taskprocessing): new command to get a task from a task ID, include error_message in list and get commandsenh/noid/taskprocessing-commands-task-errors
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/TaskProcessing/GetCommand.php41
-rw-r--r--core/Command/TaskProcessing/ListCommand.php6
2 files changed, 46 insertions, 1 deletions
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 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OC\Core\Command\TaskProcessing;
+
+use OC\Core\Command\Base;
+use OCP\TaskProcessing\IManager;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class GetCommand extends Base {
+ public function __construct(
+ protected IManager $taskProcessingManager,
+ ) {
+ parent::__construct();
+ }
+
+ protected function configure() {
+ $this
+ ->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;