-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathstatus_badge.php
More file actions
42 lines (38 loc) · 1.11 KB
/
Copy pathstatus_badge.php
File metadata and controls
42 lines (38 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Job Status Badge Element
*
* @var \Cake\View\View $this
* @var \Queue\Model\Entity\QueuedJob $job The queued job entity
*/
use Queue\Model\Table\QueuedJobsTable;
$status = 'pending';
$icon = 'clock';
if ($job->completed) {
$status = 'completed';
$icon = 'check';
} elseif ($job->status === QueuedJobsTable::STATUS_ABORTED || $job->failure_message) {
// Terminal: retries exhausted (status = aborted) or a recorded failure.
// Checked before `fetched` so a job whose worker died on its last attempt
// shows as Failed, not stuck "Running".
$status = 'failed';
$icon = 'times';
} elseif ($job->fetched) {
$status = 'running';
$icon = 'spinner fa-spin';
} elseif ($job->notbefore && $job->notbefore->isFuture()) {
$status = 'scheduled';
$icon = 'calendar';
}
$statusLabels = [
'pending' => __d('queue', 'Pending'),
'running' => __d('queue', 'Running'),
'completed' => __d('queue', 'Completed'),
'failed' => __d('queue', 'Failed'),
'scheduled' => __d('queue', 'Scheduled'),
];
?>
<span class="badge badge-<?= $status ?>">
<i class="fas fa-<?= $icon ?> me-1"></i>
<?= $statusLabels[$status] ?>
</span>