line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::bif::work; |
2
|
1
|
|
|
1
|
|
574
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
4
|
use Bif::Mo; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
686
|
use DBIx::ThinSQL qw/concat coalesce qv/; |
|
1
|
|
|
|
|
21781
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
717
|
use IO::Prompt::Tiny qw/prompt/; |
|
1
|
|
|
|
|
501
|
|
|
1
|
|
|
|
|
474
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.1.5_5'; |
9
|
|
|
|
|
|
|
extends 'App::bif'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub run { |
12
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
13
|
1
|
|
|
|
|
3
|
my $opts = $self->opts; |
14
|
1
|
|
|
|
|
7
|
my $work = $self->current_work; |
15
|
0
|
|
|
|
|
|
my $dbw = $self->dbw; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Nothing specified, just display the status |
18
|
0
|
0
|
|
|
|
|
if ( !exists $opts->{id} ) { |
19
|
0
|
0
|
|
|
|
|
if ($work) { |
20
|
|
|
|
|
|
|
printf "working %s %s %s (since %s)\n", $work->{kind}, |
21
|
|
|
|
|
|
|
$work->{path}, |
22
|
|
|
|
|
|
|
$self->s2hm( time - $work->{start} ), |
23
|
0
|
|
|
|
|
|
scalar localtime( $work->{start} ); |
24
|
0
|
|
|
|
|
|
return $self->ok('Working'); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
print "Not currently working a node.\n"; |
27
|
0
|
|
|
|
|
|
return $self->ok('NoWork'); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $epoch = $self->datetime2s( $opts->{at} ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Stop work |
33
|
0
|
0
|
|
|
|
|
if ( $opts->{id} eq '-' ) { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# But only if we were actually working |
36
|
0
|
0
|
|
|
|
|
if ($work) { |
37
|
|
|
|
|
|
|
$self->stop_work( |
38
|
|
|
|
|
|
|
stop => $epoch, |
39
|
|
|
|
|
|
|
stop_comment => $opts->{comment}, |
40
|
0
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
printf "stopped working %s %s after %s\n", $work->{kind}, |
42
|
|
|
|
|
|
|
$work->{path}, |
43
|
0
|
|
|
|
|
|
$self->s2hm( $epoch - $work->{start} ); |
44
|
0
|
|
|
|
|
|
return $self->ok('StopWork'); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
print "Not currently working a node.\n"; |
48
|
0
|
|
|
|
|
|
return $self->ok('NoWork'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check validity of ID |
52
|
0
|
|
|
|
|
|
my $info = $self->get_node( $opts->{id} ); |
53
|
0
|
|
|
|
|
|
$opts->{id} = $info->{id}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Maybe complain if we are working something else |
56
|
0
|
0
|
|
|
|
|
if ($work) { |
57
|
|
|
|
|
|
|
return $self->err( 'WorkOther', "working %s %s [%s] since %s", |
58
|
|
|
|
|
|
|
$work->{kind}, $work->{node_id}, $work->{path}, |
59
|
|
|
|
|
|
|
scalar localtime( $work->{start} ) ) |
60
|
0
|
0
|
|
|
|
|
unless $opts->{force}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
0
|
|
|
|
$opts->{comment} ||= prompt( 'Comment:', '' ); |
63
|
0
|
|
|
|
|
|
$self->stop_work( stop => $epoch - 1 ); |
64
|
|
|
|
|
|
|
printf "stopped working %s %s after %s\n", $work->{kind}, |
65
|
|
|
|
|
|
|
$work->{path}, |
66
|
0
|
|
|
|
|
|
$self->s2hm( $epoch - $work->{start} ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
0
|
|
|
|
$opts->{comment} ||= prompt( 'Comment:', '' ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Finally, start the new work |
73
|
|
|
|
|
|
|
$self->start_work( |
74
|
|
|
|
|
|
|
node_id => $info->{id}, |
75
|
|
|
|
|
|
|
start => $epoch, |
76
|
|
|
|
|
|
|
start_comment => $opts->{comment}, |
77
|
0
|
0
|
|
|
|
|
billable => $opts->{not_billable} ? 0 : 1, |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$work = $self->current_work; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
printf "working %s %s since %s\n", $work->{kind}, |
83
|
|
|
|
|
|
|
$work->{path}, |
84
|
0
|
|
|
|
|
|
scalar localtime( $work->{start} ); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $self->ok('StartWork'); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
__END__ |