Skip to content

Commit

Permalink
execute-manual (joomla#43750)
Browse files Browse the repository at this point in the history
  • Loading branch information
alikon authored Jul 11, 2024
1 parent 25168d3 commit 7133483
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions libraries/src/Console/TasksListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,22 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
$tasks = array_map(
function (\stdClass $task): array {
$enabled = $task->state === 1;
$nextExec = Factory::getDate($task->next_execution, 'UTC');
$due = $enabled && $task->taskOption && Factory::getDate('now', 'UTC') > $nextExec;
$rule = json_decode($task->execution_rules);

if ($rule->{'rule-type'} === 'manual') {
$nextRun = 'Manual';
} else {
$nextExec = Factory::getDate($task->next_execution, 'UTC');
$due = $enabled && $task->taskOption && Factory::getDate('now', 'UTC') > $nextExec;
$nextRun = $due ? 'DUE!' : $nextExec->toRFC822();
}

return [
'id' => $task->id,
'title' => $task->title,
'type' => $task->safeTypeTitle,
'state' => $task->state === 1 ? 'Enabled' : ($task->state === 0 ? 'Disabled' : 'Trashed'),
'next_execution' => $due ? 'DUE!' : $nextExec->toRFC822(),
'next_execution' => $nextRun,
];
},
$this->getTasks()
Expand All @@ -105,7 +112,7 @@ private function getTasks(): array

return $scheduler->fetchTaskRecords(
['state' => '*'],
['ordering' => 'a.title', 'select' => 'a.id, a.title, a.type, a.state, a.next_execution']
['ordering' => 'a.title', 'select' => 'a.id, a.title, a.type, a.state, a.next_execution, a.execution_rules']
);
}

Expand Down

0 comments on commit 7133483

Please sign in to comment.