line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::bif::show::project; |
2
|
1
|
|
|
1
|
|
3457
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
4
|
use Bif::Mo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.1.5_5'; |
7
|
|
|
|
|
|
|
extends 'App::bif::show'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub run { |
10
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
11
|
1
|
|
|
|
|
3
|
my $opts = $self->opts; |
12
|
1
|
|
|
|
|
5
|
my $db = $self->db; |
13
|
0
|
0
|
|
|
|
|
my $info = $self->get_project( $opts->{id} ? $opts->{id} : $opts->{path} ); |
14
|
0
|
|
|
|
|
|
my $now = $self->now; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my @data; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
DBIx::ThinSQL->import(qw/sum case coalesce concat qv/); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $ref = $db->xhashref( |
21
|
|
|
|
|
|
|
select => [ |
22
|
|
|
|
|
|
|
'nodes.id', |
23
|
|
|
|
|
|
|
'substr(nodes.uuid,1,8) as uuid', |
24
|
|
|
|
|
|
|
'nodes.path', |
25
|
|
|
|
|
|
|
'projects.title', |
26
|
|
|
|
|
|
|
'nodes.ctime AS ctime', |
27
|
|
|
|
|
|
|
'nodes.ctimetz AS ctimetz', |
28
|
|
|
|
|
|
|
'nodes.ctimetzhm AS ctimetzhm', |
29
|
|
|
|
|
|
|
"$now - nodes.ctime AS ctime_age", |
30
|
|
|
|
|
|
|
'nodes.mtime AS mtime', |
31
|
|
|
|
|
|
|
'nodes.mtimetz AS mtimetz', |
32
|
|
|
|
|
|
|
'nodes.mtimetzhm AS mtimetzhm', |
33
|
|
|
|
|
|
|
"$now - nodes.mtime AS mtime_age", |
34
|
|
|
|
|
|
|
'changes.author', |
35
|
|
|
|
|
|
|
'changes.author_contact AS contact', |
36
|
|
|
|
|
|
|
'changes.message', |
37
|
|
|
|
|
|
|
'project_status.status', |
38
|
|
|
|
|
|
|
'project_status.status', |
39
|
|
|
|
|
|
|
'projects.local', |
40
|
|
|
|
|
|
|
'hn.name AS hub', |
41
|
|
|
|
|
|
|
'hn.uuid AS hub_uuid', |
42
|
|
|
|
|
|
|
'h.location', |
43
|
|
|
|
|
|
|
], |
44
|
|
|
|
|
|
|
from => 'projects', |
45
|
|
|
|
|
|
|
inner_join => 'nodes', |
46
|
|
|
|
|
|
|
on => 'nodes.id = projects.id', |
47
|
|
|
|
|
|
|
inner_join => 'changes', |
48
|
|
|
|
|
|
|
on => 'changes.id = nodes.first_change_id', |
49
|
|
|
|
|
|
|
inner_join => 'project_status', |
50
|
|
|
|
|
|
|
on => 'project_status.id = projects.project_status_id', |
51
|
|
|
|
|
|
|
left_join => 'nodes hn', |
52
|
|
|
|
|
|
|
on => 'hn.id = projects.default_hub_id', |
53
|
|
|
|
|
|
|
left_join => 'hubs h', |
54
|
|
|
|
|
|
|
on => 'h.id = projects.default_hub_id', |
55
|
|
|
|
|
|
|
where => { 'projects.id' => $info->{id} }, |
56
|
0
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
push( @data, $self->header( ' Path', $ref->{path}, $ref->{uuid} ), ); |
59
|
|
|
|
|
|
|
push( @data, $self->header( ' Hub', $ref->{hub}, $ref->{location} ), ) |
60
|
0
|
0
|
|
|
|
|
if $ref->{hub}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if ( $opts->{full} ) { |
63
|
|
|
|
|
|
|
push( @data, |
64
|
0
|
|
|
|
|
|
$self->header( ' Creator', $ref->{author}, $ref->{contact} ), |
65
|
|
|
|
|
|
|
$self->header( ' Created', $self->ctime_ago($ref) ), |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my @phases = $db->xarrayrefs( |
70
|
|
|
|
|
|
|
select => [ |
71
|
|
|
|
|
|
|
case ( |
72
|
|
|
|
|
|
|
when => { status => $ref->{status} }, |
73
|
|
|
|
|
|
|
then => 'UPPER(status)', |
74
|
|
|
|
|
|
|
else => 'status', |
75
|
|
|
|
|
|
|
)->as('status'), |
76
|
|
|
|
|
|
|
], |
77
|
|
|
|
|
|
|
from => 'project_status', |
78
|
|
|
|
|
|
|
where => { project_id => $info->{id} }, |
79
|
0
|
|
|
|
|
|
order_by => 'rank', |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
push( @data, |
83
|
0
|
|
|
|
|
|
$self->header( ' Phases', join( ', ', map { $_->[0] } @phases ) ), |
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ( $ref->{local} ) { |
87
|
|
|
|
|
|
|
my ( $ai, $si, $ri, $ii ) = $db->xlist( |
88
|
|
|
|
|
|
|
select => [ |
89
|
|
|
|
|
|
|
coalesce( sum( { 'ist.status' => 'open' } ), 0 )->as('open'), |
90
|
|
|
|
|
|
|
coalesce( sum( { 'ist.status' => 'stalled' } ), 0 ) |
91
|
|
|
|
|
|
|
->as('stalled'), |
92
|
|
|
|
|
|
|
coalesce( sum( { 'ist.status' => 'closed' } ), 0 ) |
93
|
|
|
|
|
|
|
->as('closed'), |
94
|
|
|
|
|
|
|
coalesce( sum( { 'ist.status' => 'ignored' } ), 0 ) |
95
|
|
|
|
|
|
|
->as('ignored'), |
96
|
|
|
|
|
|
|
], |
97
|
|
|
|
|
|
|
from => 'issue_status ist', |
98
|
|
|
|
|
|
|
inner_join => 'issues i', |
99
|
|
|
|
|
|
|
on => 'i.issue_status_id = ist.id', |
100
|
|
|
|
|
|
|
where => { 'ist.project_id' => $info->{id} }, |
101
|
0
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my ( $at, $st, $rt, $it ) = $db->xlist( |
104
|
|
|
|
|
|
|
select => [ |
105
|
|
|
|
|
|
|
coalesce( sum( { status => 'open' } ), 0 )->as('open'), |
106
|
|
|
|
|
|
|
coalesce( sum( { status => 'stalled' } ), 0 )->as('stalled'), |
107
|
|
|
|
|
|
|
coalesce( sum( { status => 'closed' } ), 0 )->as('closed'), |
108
|
|
|
|
|
|
|
coalesce( sum( { status => 'ignored' } ), 0 )->as('ignored'), |
109
|
|
|
|
|
|
|
], |
110
|
|
|
|
|
|
|
from => 'task_status', |
111
|
|
|
|
|
|
|
inner_join => 'tasks', |
112
|
|
|
|
|
|
|
on => 'tasks.task_status_id = task_status.id', |
113
|
|
|
|
|
|
|
where => { 'task_status.project_id' => $info->{id} }, |
114
|
0
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $total_issues = $ai + $si + $ri; |
117
|
0
|
|
|
|
|
|
my $total_tasks = $at + $st + $rt; |
118
|
0
|
|
|
|
|
|
my $total = $total_issues + $total_tasks; |
119
|
0
|
0
|
|
|
|
|
my $progress = $total ? int( ( ( $ri + $rt ) / $total ) * 100 ) : 0; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
push( |
122
|
|
|
|
|
|
|
@data, |
123
|
|
|
|
|
|
|
$self->header( ' Progress', $progress . '%' ), |
124
|
|
|
|
|
|
|
$self->header( |
125
|
|
|
|
|
|
|
' Tasks', "$at open, $st stalled, $rt closed, $it ignored" |
126
|
|
|
|
|
|
|
), |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# TODO "Updated:..." |
129
|
|
|
|
|
|
|
$self->header( |
130
|
|
|
|
|
|
|
' Issues', "$ai open, $si stalled, $ri closed, $ii ignored" |
131
|
|
|
|
|
|
|
), |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# TODO "Updated:..." |
134
|
|
|
|
|
|
|
$self->header( ' Updated', $self->mtime_ago($ref) ), |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if ( $opts->{full} ) { |
139
|
0
|
|
|
|
|
|
require Text::Autoformat; |
140
|
|
|
|
|
|
|
push( |
141
|
|
|
|
|
|
|
@data, |
142
|
|
|
|
|
|
|
$self->header( |
143
|
|
|
|
|
|
|
'Description', |
144
|
|
|
|
|
|
|
Text::Autoformat::autoformat( |
145
|
|
|
|
|
|
|
$ref->{message}, |
146
|
|
|
|
|
|
|
{ |
147
|
0
|
|
|
|
|
|
right => 60, |
148
|
|
|
|
|
|
|
all => 1 |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
) |
151
|
|
|
|
|
|
|
), |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
} |
154
|
0
|
|
|
|
|
|
$self->start_pager; |
155
|
0
|
|
|
|
|
|
print $self->render_table( 'l l', [ 'Project', $ref->{title} ], \@data, |
156
|
|
|
|
|
|
|
1 ); |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
print "\n"; |
159
|
|
|
|
|
|
|
$self->dispatch( 'App::bif::log::project', |
160
|
0
|
|
|
|
|
|
{ opts => { path => $info->{path} } } ); |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return $self->ok( 'ShowProject', \@data ); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |
166
|
|
|
|
|
|
|
__END__ |