| 1 | package App::TimeTracker::Command::Category; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: use categories when tracking time with App::TimeTracker | ||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '1.003'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub munge_start_attribs { | ||||||||||||||||||||||||||
|
Subroutine
munge_start_attribs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ( $class, $meta, $config ) = @_; | |||||||||||||||||||||||||||
| 15 | 0 | my $cfg = $config->{category}; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | return unless $cfg && $cfg->{categories}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cfg and $cfg->{"categories"}
MC/DC0%0/2
$cfg and $cfg->{"categories"}
$cfg
$cfg->{"categories"}
Truth table0%0/3
A and B
A= $cfgB= $cfg->{"categories"}
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | subtype 'ATT::Category' => as enum( $cfg->{categories} ) => message { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 19 | 0 | "$_ is not a valid category (as defined in the current config)" | |||||||||||||||||||||||||||
| 20 | 0 | }; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $meta->add_attribute( | ||||||||||||||||||||||||||||
| 23 | 'category' => { | ||||||||||||||||||||||||||||
| 24 | isa => 'ATT::Category', | ||||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||
| 26 | required => $cfg->{required}, | ||||||||||||||||||||||||||||
| 27 | 0 | documentation => 'Category', | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 1 | after '_load_attribs_start' => \&munge_start_attribs; | |||||||||||||||||||||||||||
| 32 | 1 | after '_load_attribs_append' => \&munge_start_attribs; | |||||||||||||||||||||||||||
| 33 | 1 | after '_load_attribs_continue' => \&munge_start_attribs; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | before [ 'cmd_start', 'cmd_continue', 'cmd_append' ] => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return unless my $category = $self->category; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if (my $prefix = $self->config->{category}{prefix}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | $category = $prefix.$category; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | $self->add_tag( $category ); | |||||||||||||||||||||||||||
| 44 | 1 | }; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub cmd_statistic { | ||||||||||||||||||||||||||
|
Subroutine
cmd_statistic: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my @files = $self->find_task_files( | |||||||||||||||||||||||||||
| 50 | { from => $self->from, | ||||||||||||||||||||||||||||
| 51 | to => $self->to, | ||||||||||||||||||||||||||||
| 52 | projects => $self->fprojects, | ||||||||||||||||||||||||||||
| 53 | tags => $self->ftags, | ||||||||||||||||||||||||||||
| 54 | parent => $self->fparent, | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | 0 | my $cats = $self->config->{category}{categories}; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $prefix = $self->config->{category}{prefix} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->config->{'category'}{'prefix'} || ''
MC/DC0%0/1
$self->config->{'category'}{'prefix'} || ''
$self->config->{'category'}{'prefix'}
Truth table0%0/2
A
A= $self->config->{'category'}{'prefix'}
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | my $total = 0; | |||||||||||||||||||||||||||
| 61 | 0 | my %stats; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | foreach my $file (@files) { | |||||||||||||||||||||||||||
| 64 | 0 | my $task = App::TimeTracker::Data::Task->load( $file->stringify ); | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $time = $task->seconds // $task->_build_seconds; | ||||||||||||||||||||||||||
|
Condition0%0/3
$task->seconds // $task->_build_seconds
MC/DC0%0/2
$task->seconds // $task->_build_seconds
$task->seconds
$task->_build_seconds
Truth table0%0/3
A // B
A= $task->secondsB= $task->_build_seconds
| |||||||||||||||||||||||||||||
| 66 | 0 | $total += $time; | |||||||||||||||||||||||||||
| 67 | 0 | my %tags = map { $_ => 1 } @{ $task->tags }; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | my $got_cat = 0; | |||||||||||||||||||||||||||
| 70 | 0 | foreach my $cat (@$cats) { | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $tags{$prefix.$cat} || $tags{$cat} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tags{$prefix . $cat} or $tags{$cat}
MC/DC0%0/2
$tags{$prefix . $cat} or $tags{$cat}
$tags{$prefix . $cat}
$tags{$cat}
Truth table0%0/3
A or B
A= $tags{$prefix . $cat}B= $tags{$cat}
| |||||||||||||||||||||||||||||
| 72 | 0 | $stats{$cat}{abs} += $time; | |||||||||||||||||||||||||||
| 73 | 0 | $got_cat = 1; | |||||||||||||||||||||||||||
| 74 | 0 | last; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $stats{_no_cat}{abs} += $time unless $got_cat; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | while ( my ( $cat, $data ) = each %stats ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $data->{percent} = sprintf( "%.1f", $data->{abs} / $total * 100 ); | |||||||||||||||||||||||||||
| 82 | 0 | $data->{nice} = $self->beautify_seconds( $data->{abs} ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | $self->_say_current_report_interval; | |||||||||||||||||||||||||||
| 86 | 0 | printf( "%39s\n", $self->beautify_seconds($total) ); | |||||||||||||||||||||||||||
| 87 | 0 | foreach my $cat ( sort keys %stats ) { | |||||||||||||||||||||||||||
| 88 | 0 | my $data = $stats{$cat}; | |||||||||||||||||||||||||||
| 89 | printf( "%6s%% %- 20s% 10s\n", | ||||||||||||||||||||||||||||
| 90 | 0 | $data->{percent}, $cat, $data->{nice} ); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub _load_attribs_statistic { | ||||||||||||||||||||||||||
|
Subroutine
_load_attribs_statistic: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 95 | 0 | my ( $class, $meta ) = @_; | |||||||||||||||||||||||||||
| 96 | 0 | $class->_load_attribs_worked($meta); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 1 | 1; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||