GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CheckJobHealthTask::getService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Symbiote\QueuedJobs\Tasks;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Dev\BuildTask;
7
use Symbiote\QueuedJobs\Services\QueuedJob;
8
use Symbiote\QueuedJobs\Services\QueuedJobService;
9
10
class CheckJobHealthTask extends BuildTask
11
{
12
    /**
13
     * {@inheritDoc}
14
     * @var string
15
     */
16
    private static $segment = 'CheckJobHealthTask';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
17
18
    /**
19
     * {@inheritDoc}
20
     * @return string
21
     */
22
    public function getDescription()
23
    {
24
        return _t(
25
            __CLASS__ . '.Description',
26
            'A task used to check the health of jobs that are "running". Pass a specific queue as the "queue" ' .
27
            'parameter or otherwise the "Queued" queue will be checked'
28
        );
29
    }
30
31
    /**
32
     * Implement this method in the task subclass to
33
     * execute via the TaskRunner
34
     *
35
     * @param HTTPRequest $request
36
     * @return
37
     */
38
    public function run($request)
39
    {
40
        $queue = $request->requestVar('queue') ?: QueuedJob::QUEUED;
41
42
        $stalledJobCount = $this->getService()->checkJobHealth($queue);
43
44
        echo $stalledJobCount === 0 ? 'All jobs are healthy' : 'Detected and attempted restart on ' . $stalledJobCount .
45
            ' stalled jobs';
46
    }
47
48
    protected function getService()
49
    {
50
        return QueuedJobService::singleton();
51
    }
52
}
53