| 1 | package Qless::ClientJobs; | ||||||||||||||||||||||
| 2 | =head1 NAME | ||||||||||||||||||||||
| 3 | |||||||||||||||||||||||
| 4 | Qless::ClientJobs | ||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | =cut | ||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON::XS qw(decode_json encode_json); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 1 | ▶ | use Qless::Job; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 1 | ▶ | use Qless::RecurringJob; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | 1 | ▶ | use Qless::Utils qw(fix_empty_array); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | =head1 METHODS | ||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | =head2 C<new> | ||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 19 | 0 | my $class = shift; | |||||||||||||||||||||
| 20 | 0 | my ($client) = @_; | |||||||||||||||||||||
| 21 | |||||||||||||||||||||||
| 22 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 23 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||
| 24 | |||||||||||||||||||||||
| 25 | 0 | $self->{'client'} = $client; | |||||||||||||||||||||
| 26 | |||||||||||||||||||||||
| 27 | 0 | $self; | |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | =head2 C<complete([$offset, $count])> | ||||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | Return the paginated jids of complete jobs | ||||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||||
| 34 | 0 | ▶ | sub complete { | ||||||||||||||||||||
|
Subroutine
complete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||
| 35 | 0 | my ($self, $offset, $count) = @_; | |||||||||||||||||||||
| 36 | 0 | ▶ | return $self->{'client'}->_jobs([], 'complete', $offset||0, $count||25); | ||||||||||||||||||||
|
Condition0%0/4
$offset || 0
$count || 25
MC/DC0%0/1
$offset || 0
$offset
MC/DC0%0/1
$count || 25
$count
Truth table0%0/2
A
A= $offset
Truth table0%0/2
A
A= $count
| |||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | =head2 C<tracked> | ||||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | Return an array of job objects that are being tracked | ||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||
| 43 | 0 | ▶ | sub tracked { | ||||||||||||||||||||
|
Subroutine
tracked: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 44 | 0 | my ($self) = @_; | |||||||||||||||||||||
| 45 | 0 | my $results = decode_json($self->{'client'}->_track()); | |||||||||||||||||||||
| 46 | 0 | $results->{'jobs'} = fix_empty_array($results->{'jobs'}); | |||||||||||||||||||||
| 47 | 0 | $results->{'jobs'} = [ map { Qless::Job->new($self, $_) } @{ $results->{'jobs'} } ]; | |||||||||||||||||||||
| 48 | 0 | return $results; | |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | =head2 C<tagged($tag[, $offset, $count])> | ||||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | Return the paginated jids of jobs tagged with a tag | ||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||
| 55 | 0 | ▶ | sub tagged { | ||||||||||||||||||||
|
Subroutine
tagged: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||
| 56 | 0 | my ($self, $tag, $offset, $count) = @_; | |||||||||||||||||||||
| 57 | 0 | ▶ | my $results = decode_json($self->{'client'}->_tag([], 'get', $tag, $offset||0, $count||25)); | ||||||||||||||||||||
|
Condition0%0/4
$offset || 0
$count || 25
MC/DC0%0/1
$offset || 0
$offset
MC/DC0%0/1
$count || 25
$count
Truth table0%0/2
A
A= $offset
Truth table0%0/2
A
A= $count
| |||||||||||||||||||||||
| 58 | 0 | $results->{'jobs'} = fix_empty_array($results->{'jobs'}); | |||||||||||||||||||||
| 59 | 0 | return $results; | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||
| 61 | |||||||||||||||||||||||
| 62 | =head2 C<failed([$group, $offset, $count])> | ||||||||||||||||||||||
| 63 | |||||||||||||||||||||||
| 64 | If no group is provided, this returns a JSON blob of the counts of the various types of failures known. | ||||||||||||||||||||||
| 65 | If a type is provided, returns paginated job objects affected by that kind of failure. | ||||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||||
| 67 | 0 | ▶ | sub failed { | ||||||||||||||||||||
|
Subroutine
failed: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||
| 68 | 0 | my ($self, $group, $offset, $count) = @_; | |||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 0 | my $results; | |||||||||||||||||||||
| 71 | 0 | ▶ | if (!$group) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 72 | 0 | $results = decode_json($self->{'client'}->_failed()); | |||||||||||||||||||||
| 73 | 0 | return $results; | |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||
| 75 | |||||||||||||||||||||||
| 76 | 0 | ▶ | $results = decode_json($self->{'client'}->_failed([], $group, $offset||0, $count||25)); | ||||||||||||||||||||
|
Condition0%0/4
$offset || 0
$count || 25
MC/DC0%0/1
$offset || 0
$offset
MC/DC0%0/1
$count || 25
$count
Truth table0%0/2
A
A= $offset
Truth table0%0/2
A
A= $count
| |||||||||||||||||||||||
| 77 | 0 | $results->{'jobs'} = fix_empty_array($results->{'jobs'}); | |||||||||||||||||||||
| 78 | 0 | $results->{'jobs'} = [ map { Qless::Job->new($self->{'client'}, $_) } @{ $results->{'jobs'} } ]; | |||||||||||||||||||||
| 79 | 0 | return $results; | |||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||
| 81 | |||||||||||||||||||||||
| 82 | =head2 C<item($jid)> | ||||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | Get a job object corresponding to that jid, or C<undef> if it doesn't exist | ||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||
| 86 | 0 | ▶ | sub item { | ||||||||||||||||||||
|
Subroutine
item: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||
| 87 | 0 | my ($self, $jid) = @_; | |||||||||||||||||||||
| 88 | |||||||||||||||||||||||
| 89 | 0 | my $results = $self->{'client'}->_get([], $jid); | |||||||||||||||||||||
| 90 | 0 | ▶ | if (!$results) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 91 | 0 | $results = $self->{'client'}->_recur([], 'get', $jid); | |||||||||||||||||||||
| 92 | 0 | ▶ | return undef if !$results; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 93 | |||||||||||||||||||||||
| 94 | 0 | return Qless::RecurringJob->new($self->{'client'}, decode_json($results)); | |||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | 0 | return Qless::Job->new($self->{'client'}, decode_json($results)); | |||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||
| 99 | |||||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | 1 | 1; | |||||||||||||||||||||