File Coverage

blib/lib/TheSchwartz/Moosified/JobHandle.pm
Criterion Covered Total %
statement 9 43 20.9
branch 0 4 0.0
condition n/a
subroutine 3 8 37.5
pod 0 5 0.0
total 12 60 20.0


line stmt bran cond sub pod time code
1             package TheSchwartz::Moosified::JobHandle;
2              
3 2     2   8 use TheSchwartz::Moosified::Job;
  2         2  
  2         50  
4 2     2   6 use Moose;
  2         2  
  2         8  
5              
6             has 'jobid' => ( is => 'rw', isa => 'Int' );
7             has 'client' => ( is => 'rw', isa => 'Object' );
8             has 'dbh' => ( is => 'rw', isa => 'Object' );
9              
10             sub job {
11 0     0 0   my $handle = shift;
12            
13 0           my $dbh = $handle->dbh;
14 0           my $table_job = $handle->client->prefix . 'job';
15 0           my $sql = qq~SELECT * FROM $table_job WHERE jobid = ?~;
16 0           my $sth = $dbh->prepare_cached($sql);
17 0           $sth->execute($handle->jobid);
18 0           my $row = $sth->fetchrow_hashref;
19 0           $sth->finish;
20 0 0         if ($row) {
21 0           my $job = TheSchwartz::Moosified::Job->new( $row );
22 0           $job->handle($handle);
23 0           return $job;
24             }
25             }
26              
27             sub is_pending {
28 0     0 0   my $handle = shift;
29 0 0         return $handle->job ? 1 : 0;
30             }
31              
32             sub exit_status {
33 0     0 0   my $handle = shift;
34            
35 0           my $dbh = $handle->dbh;
36 0           my $table_exitstatus = $handle->client->prefix . 'exitstatus';
37 0           my $sql = qq~SELECT status FROM $table_exitstatus WHERE jobid = ?~;
38 0           my $sth = $dbh->prepare($sql);
39 0           $sth->execute($handle->jobid);
40 0           my ($status) = $sth->fetchrow_array;
41 0           return $status;
42             }
43              
44             sub failure_log {
45 0     0 0   my $handle = shift;
46            
47 0           my $dbh = $handle->dbh;
48 0           my $table_error = $handle->client->prefix . 'error';
49 0           my $sql = qq~SELECT message FROM $table_error WHERE jobid = ?~;
50 0           my $sth = $dbh->prepare($sql);
51 0           $sth->execute($handle->jobid);
52            
53 0           my @failures;
54 0           while (my ($message) = $sth->fetchrow_array) {
55 0           push @failures, $message;
56             }
57 0           return @failures;
58             }
59              
60             sub failures {
61 0     0 0   my $handle = shift;
62 0           return scalar $handle->failure_log;
63             }
64              
65 2     2   8175 no Moose;
  2         2  
  2         6  
66             1;
67             __END__