File Coverage

blib/lib/App/bif/show/task.pm
Criterion Covered Total %
statement 12 32 37.5
branch 0 2 0.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 17 39 43.5


line stmt bran cond sub pod time code
1             package App::bif::show::task;
2 1     1   6428 use strict;
  1         3  
  1         48  
3 1     1   9 use warnings;
  1         9  
  1         54  
4 1     1   6 use Bif::Mo;
  1         3  
  1         13  
5              
6             our $VERSION = '0.1.5_5';
7             extends 'App::bif::show';
8              
9             sub run {
10 1     1 1 3 my $self = shift;
11 1         10 my $opts = $self->opts;
12 1         13 my $db = $self->db;
13              
14 0           $opts->{id} = $self->uuid2id( $opts->{id} );
15              
16 0           my $info = $self->get_node( $opts->{id}, 'task' );
17 0           my $now = $self->now;
18              
19 0           DBIx::ThinSQL->import(qw/sum qv concat coalesce/);
20              
21             my $ref = $db->xhashref(
22             select => [
23             'n.id AS id',
24             'n.uuid as uuid',
25             'n.path AS path',
26             'hn.name AS hub',
27             'h.location',
28             'substr(n2.uuid,1,8) AS project_uuid',
29             'tasks.title AS title',
30             'n.ctime AS ctime',
31             'n.ctimetz AS ctimetz',
32             'n.ctimetzhm AS ctimetzhm',
33             "$now - n.ctime AS ctime_age",
34             'c2.mtime AS mtime',
35             'c2.mtimetz AS mtimetz',
36             'c2.mtimetzhm AS mtimetzhm',
37             "$now - c2.mtime AS mtime_age",
38             'c1.author AS author',
39             "c1.author_contact_method || ': ' || c1.author_contact AS contact",
40             'c1.message AS message',
41             'ts.status AS status',
42             'c12.mtime AS smtime',
43             'e1.name as creator',
44             'e2.name as updator',
45             ],
46             from => 'nodes n',
47             inner_join => 'changes c1',
48             on => 'c1.id = n.first_change_id',
49             inner_join => 'entities e1',
50             on => 'e2.id = c2.identity_id',
51             inner_join => 'changes c2',
52             on => 'c2.id = n.last_change_id',
53             inner_join => 'entities e2',
54             on => 'e1.id = c1.identity_id',
55             inner_join => 'tasks',
56             on => 'tasks.id = n.id',
57             inner_join => 'task_status ts',
58             on => 'ts.id = tasks.task_status_id',
59             inner_join => 'projects p',
60             on => 'p.id = ts.project_id',
61             left_join => 'nodes hn',
62             on => 'hn.id = p.default_hub_id',
63             left_join => 'hubs h',
64             on => 'h.id = p.default_hub_id',
65             inner_join => 'nodes n2',
66             on => 'n2.id = p.id',
67             inner_join => 'changes AS c12',
68             on => 'c12.id = tasks.change_id',
69 0           where => [ 'n.id = ', qv( $info->{id} ) ],
70             );
71              
72 0           my @data;
73 0           my ( $t1, $t2 ) = $self->ctime_ago($ref);
74              
75 0           my $yellow = $self->colours('yellow');
76              
77             push(
78             @data,
79             $self->header(
80             $yellow . 'Task',
81             $yellow . $ref->{id},
82             $yellow . $ref->{uuid}
83             )
84 0           );
85              
86 0           push( @data, $self->header( ' Title', $ref->{title} ) );
87              
88 0           push(
89             @data,
90             $self->header(
91             ' Status', "$ref->{status} [$ref->{path} ($ref->{id})]"
92             )
93             );
94              
95 0 0         if ( $opts->{full} ) {
96 0           require Text::Autoformat;
97             push(
98             @data,
99             $self->header(
100             'Description',
101             Text::Autoformat::autoformat(
102             $ref->{message},
103             {
104 0           right => 60,
105             all => 1
106             }
107             )
108             ),
109             );
110             }
111              
112 0           ( $t1, $t2 ) = $self->mtime_ago($ref);
113              
114 0           $self->start_pager;
115 0           print $self->render_table( 'l l', undef, \@data, 1 );
116              
117 0           print "\n";
118 0           $self->dispatch( 'App::bif::log::task', { opts => { id => $opts->{id} } } );
119              
120 0           $self->ok( 'ShowTask', \@data );
121              
122             }
123              
124             1;
125             __END__