File Coverage

blib/lib/App/bif/drop/task.pm
Criterion Covered Total %
statement 12 23 52.1
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 31 54.8


line stmt bran cond sub pod time code
1             package App::bif::drop::task;
2 1     1   3404 use strict;
  1         2  
  1         35  
3 1     1   3 use warnings;
  1         2  
  1         43  
4 1     1   6 use Bif::Mo;
  1         2  
  1         8  
5              
6             our $VERSION = '0.1.5_5';
7             extends 'App::bif';
8              
9             sub run {
10 1     1 1 2 my $self = shift;
11 1         3 my $opts = $self->opts;
12 1         5 my $dbw = $self->dbw;
13 0           my $info = $self->get_node( $opts->{id}, 'task' );
14              
15 0 0         if ( !$opts->{force} ) {
16 0           print "Nothing dropped (missing --force, -f)\n";
17 0           return $self->ok('DropNoForce');
18             }
19              
20 0           my $uuid = substr( $info->{uuid}, 0, 8 );
21              
22             $dbw->txn(
23             sub {
24 0     0     $self->start_work(
25             start => time,
26             start_comment => "drop task $info->{id} <$uuid>",
27             billable => 0,
28             save => 1,
29             );
30              
31             # TODO: copy existing work_deltas rows into work_buffers
32             # with NULL node_id so that the work activity is not lost.
33             # Perhaps a new --no-work-buffer option or similar to
34             # disable that behaviour.
35             $dbw->xdo(
36             delete_from => 'tasks',
37             where => { id => $info->{id} },
38 0           );
39              
40 0           print "Task dropped: $info->{id} <$uuid>\n";
41              
42 0           $self->stop_work(
43             stop => time,
44             restore => 1,
45             );
46             }
47 0           );
48              
49 0           return $self->ok('DropTask');
50             }
51              
52             1;
53             __END__