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