l10n->t('Task Processing pickup speed'); } public function run(): SetupResult { $taskCount = 0; $lastNDays = 0; while ($taskCount === 0 && $lastNDays < self::MAX_DAYS) { $lastNDays++; // userId: '' means no filter, whereas null would mean guest $tasks = $this->taskProcessingManager->getTasks(userId: '', scheduleAfter: $this->timeFactory->now()->getTimestamp() - (60 * 60 * 24 * $lastNDays)); $taskCount = count($tasks); } if ($taskCount === 0) { return SetupResult::success( $this->l10n->n( 'No scheduled tasks in the last day.', 'No scheduled tasks in the last %n days.', $lastNDays ) ); } $failedCount = 0; foreach ($tasks as $task) { if ($task->getEndedAt() === null) { continue; // task was not picked up yet } $status = $task->getStatus(); if ($status === Task::STATUS_FAILED) { $failedCount++; } } if (($failedCount / $taskCount) < self::MAX_FAILURE_PERCENTAGE) { return SetupResult::success( $this->l10n->n( 'Most tasks were successful in the last day.', 'Most tasks were successful in the last %n days.', $lastNDays ) ); } else { return SetupResult::warning( $this->l10n->n( 'A lot of tasks failed in the last day. Consider checking the nextcloud log for errors and investigating whether the AI provider apps have been set up correctly.', 'A lot of tasks failed in the last %n days. Consider checking the nextcloud log for errors and investigating whether the AI provider apps have been set up correctly.', $lastNDays ), 'https://docs.nextcloud.com/server/latest/admin_manual/ai/insight_and_debugging.html' ); } } }