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.
Completed
Pull Request — master (#214)
by
unknown
01:39
created

CheckJobHealthTask   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 8 1
A run() 0 9 3
A getService() 0 4 1
1
<?php
2
namespace Symbiote\QueuedJobs\Tasks;
3
4
use SilverStripe\Control\HTTPRequest;
5
use SilverStripe\Dev\BuildTask;
6
use Symbiote\QueuedJobs\Services\QueuedJob;
7
use Symbiote\QueuedJobs\Services\QueuedJobService;
8
9
class CheckJobHealthTask extends BuildTask
10
{
11
    /**
12
     * {@inheritDoc}
13
     * @var string
14
     */
15
    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...
16
17
    /**
18
     * {@inheritDoc}
19
     * @return string
20
     */
21
    public function getDescription()
22
    {
23
        return _t(
24
            __CLASS__ . '.Description',
25
            'A task used to check the health of jobs that are "running". Pass a specific queue as the "queue" ' .
26
            'parameter or otherwise the "Queued" queue will be checked'
27
        );
28
    }
29
30
    /**
31
     * Implement this method in the task subclass to
32
     * execute via the TaskRunner
33
     *
34
     * @param HTTPRequest $request
35
     * @return
36
     */
37
    public function run($request)
38
    {
39
        $queue = $request->requestVar('queue') ?: QueuedJob::QUEUED;
40
41
        $stalledJobCount = $this->getService()->checkJobHealth($queue);
42
43
        echo $stalledJobCount === 0 ? 'All jobs are healthy' : 'Detected and attempted restart on ' . $stalledJobCount .
44
            ' stalled jobs';
45
    }
46
47
    protected function getService()
48
    {
49
        return QueuedJobService::singleton();
50
    }
51
}
52