Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(settings): Improve TaskProcessingPickupSpeed setup check
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Oct 13, 2025
commit 5a48887a2bd5659a1da820bd8577e8ae9d86ae55
37 changes: 31 additions & 6 deletions apps/settings/lib/SetupChecks/TaskProcessingPickupSpeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

class TaskProcessingPickupSpeed implements ISetupCheck {
public const MAX_SLOW_PERCENTAGE = 0.2;
public const TIME_SPAN = 24;

public const MAX_DAYS = 14;

public function __construct(
private IL10N $l10n,
Expand All @@ -35,10 +36,21 @@ public function getName(): string {
}

public function run(): SetupResult {
$tasks = $this->taskProcessingManager->getTasks(userId: '', scheduleAfter: $this->timeFactory->now()->getTimestamp() - 60 * 60 * self::TIME_SPAN); // userId: '' means no filter, whereas null would mean guest
$taskCount = count($tasks);
$taskCount = 0;
$lastNDays = 1;
while($taskCount === 0 && $lastNDays < self::MAX_DAYS) {
$lastNDays++;
$tasks = $this->taskProcessingManager->getTasks(userId: '', scheduleAfter: $this->timeFactory->now()->getTimestamp() - 60 * 60 * 24 * $lastNDays); // userId: '' means no filter, whereas null would mean guest
$taskCount = count($tasks);
}
if ($taskCount === 0) {
return SetupResult::success($this->l10n->n('No scheduled tasks in the last %n hour.', 'No scheduled tasks in the last %n hours.', self::TIME_SPAN));
return SetupResult::success(
$this->l10n->n(
'No scheduled tasks in the last %n hour.',
'No scheduled tasks in the last %n hours.',
24 * $lastNDays
)
);
}
$slowCount = 0;
foreach ($tasks as $task) {
Expand All @@ -55,9 +67,22 @@ public function run(): SetupResult {
}

if ($slowCount / $taskCount < self::MAX_SLOW_PERCENTAGE) {
return SetupResult::success($this->l10n->n('The task pickup speed has been ok in the last %n hour.', 'The task pickup speed has been ok in the last %n hours.', self::TIME_SPAN));
return SetupResult::success(
$this->l10n->n(
'The task pickup speed has been ok in the last %n hour.',
'The task pickup speed has been ok in the last %n hours.',
24 * $lastNDays
)
);
} else {
return SetupResult::warning($this->l10n->n('The task pickup speed has been slow in the last %n hour. Many tasks took longer than 4 minutes to be picked up. Consider setting up a worker to process tasks in the background.', 'The task pickup speed has been slow in the last %n hours. Many tasks took longer than 4 minutes to be picked up. Consider setting up a worker to process tasks in the background.', self::TIME_SPAN), 'https://docs.nextcloud.com/server/latest/admin_manual/ai/overview.html#improve-ai-task-pickup-speed');
return SetupResult::warning(
$this->l10n->n(
'The task pickup speed has been slow in the last %n hour. Many tasks took longer than 4 minutes to be picked up. Consider setting up a worker to process tasks in the background.',
'The task pickup speed has been slow in the last %n hours. Many tasks took longer than 4 minutes to be picked up. Consider setting up a worker to process tasks in the background.',
24 * $lastNDays
),
'https://docs.nextcloud.com/server/latest/admin_manual/ai/overview.html#improve-ai-task-pickup-speed'
);
}
}
}
Loading