blib/lib/Tapper/Reports/Web/Controller/Tapper/Overview.pm

filter: Statementstmt 30.8% 21 / 68 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 46.1% 6 / 13 Podpod 0.0% 0 / 6 totaltotal 22.3% 27 / 121 CC 16 SCAR 35.3
CC
16
Cov
21%
index
90.0
suite
20.0
recently_used_suites
12.0
CRAP 34.3
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Rss.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Tapper/Testruns.pm »
1 package Tapper::Reports::Web::Controller::Tapper::Overview;
2 13 our $AUTHORITY = 'cpan:TAPPER';
3 13 $Tapper::Reports::Web::Controller::Tapper::Overview::VERSION = '5.0.17';
4 13 ▶use parent 'Tapper::Reports::Web::Controller::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Tapper::Reports::Web::Util::Filter::Overview;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 ## no critic (RequireUseStrict)
9  
10 0 ▶sub auto :Private
Subroutine auto: not called CC=1 SCAR=6.9
11 {
12 0 my ( $self, $c ) = @_;
13 0 $c->forward('/tapper/overview/prepare_navi');
14 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 # Filter suite list so that only recently used suites are given.
18 #
19 # @param suite result set - unfiltered suites
20 # @param int/string - duration
21 #
22 # @return suite result set - filtered suites
23 #
24 sub recently_used_suites
25 0 ▶{
Subroutine recently_used_suites: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my ($self, $c, $suite_rs, $duration) = @_;
27 0 my $timeframe;
28 0 ▶ if ($duration) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration) { } 0 0 0
29 0 ▶ return $suite_rs if lc($duration) eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if lc $duration eq "all" 0 0 0
30 0 $timeframe = DateTime->now->subtract(weeks => $duration);
31 } else {
32 0 $timeframe = DateTime->now->subtract(weeks => 12);
33 }
34 0 my $dtf = $c->model("TestrunDB")->storage->datetime_parser;
35 0 $suite_rs = $suite_rs->search({'reports.created_at' => {'>=' => $dtf->format_datetime($timeframe) }});
36 0 return $suite_rs;
37 }
38  
39  
40 0 ▶sub index :Path :Args()
Subroutine index: not called CC=9 SCAR=45.0
Pod undocumented
41 {
42 0 my ( $self, $c, $type, @args ) = @_;
43  
44 0 my $filter = Tapper::Reports::Web::Util::Filter::Overview->new(context => $c);
45 0 my $filter_condition;
46 0 ▶ if (not (@args == 1 and lc($args[0]) eq 'all')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@args == 1 and lc $args[0] eq "all") 0 0 0
Condition0%0/3
@args == 1 and lc $args[0] eq "all"
!ll&&!rl&&r
000
MC/DC0%0/2
@args == 1 and lc $args[0] eq "all"
@args == 1 lc $args[0] eq "all"
Truth table0%0/3
A and B
A= @args == 1B= lc $args[0] eq "all"
ABresult
0X0
100
111
47 0 $filter_condition = $filter->parse_filters(\@args);
48 }
49  
50 0 ▶ if ($filter_condition->{error}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filter_condition->{"error"}) 0 0 0
51 0 $c->stash->{error_msg} = join("; ", @{$filter_condition->{error}});
52 0 $c->res->redirect("/tapper/overview/");
53 }
54 $filter_condition->{early} = {} unless
55 defined($filter_condition->{early}) and
56 0 ▶ ref($filter_condition->{early}) eq 'HASH' ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filter_condition->{"early"} and ref $filter_condition->{"early"} eq "HASH" 0 0 0
Condition0%0/3
defined $filter_condition->{"early"} and ref $filter_condition->{"early"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $filter_condition->{"early"} and ref $filter_condition->{"early"} eq "HASH"
defined $filter_condition->{"early"} ref $filter_condition->{"early"} eq "HASH"
Truth table0%0/3
A and B
A= defined $filter_condition->{"early"}B= ref $filter_condition->{"early"} eq "HASH"
ABresult
0X0
100
111
57  
58 0 ▶ if ($type eq 'suite') {$self->suite($c, $filter_condition)}
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'suite') { } 0 0 0
elsif ($type eq 'host') { } 0 0 0
elsif ($type eq 'resource') { } 0 0 0
59 0 elsif ($type eq 'host') {$self->host($c, $filter_condition)}
60 0 elsif ($type eq 'resource') {$self->resource($c, $filter_condition)}
61 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 sub suite
64 0 ▶{
Subroutine suite: not called CC=4 SCAR=30.0
Pod undocumented
65 0 my ( $self, $c, $filter_condition ) = @_;
66  
67 0 my %search_options = ( prefetch => ['reports'] );
68  
69 0 my $suite_rs = $c->model('TestrunDB')->resultset('Suite')->search($filter_condition->{early}, { %search_options } );
70 0 foreach my $filter (@{$filter_condition->{late}}) {
71 0 $suite_rs = $suite_rs->search($filter);
72 }
73 0 $c->stash->{overviews} = {};
74 0 ▶ while ( my $suite = $suite_rs->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $suite = $suite_rs->next) 0 0 0
75 0 ▶ $c->stash->{overviews}{$suite->name} = '/tapper/reports/suite/'.($suite->name =~ /[^\w\d_.-]/ ? $suite->id : $suite->name);
Branch: 1 branch
BranchTrueFalseTotal
$suite->name =~ /[^\w\d_.-]/ ? : 0 0 0
76 }
77 0 $c->stash->{title} = "Tapper report suites";
78 }
79  
80 sub host
81 0 ▶{
Subroutine host: not called CC=2 SCAR=17.9
Pod undocumented
82 0 my ( $self, $c, $filter_condition ) = @_;
83  
84 my $reports = $c->model('TestrunDB')->resultset('Report')->search($filter_condition->{early},
85 0 { columns => [ qw/machine_name/ ],
86 distinct => 1,
87 });
88 0 ▶ while ( my $report = $reports->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $report = $reports->next) 0 0 0
89 0 $c->stash->{overviews}{$report->machine_name} = '/tapper/reports/host/'.$report->machine_name;
90 }
91 0 $c->stash->{title} = "Tapper report hosts";
92 }
93  
94 sub resource
95 0 ▶{
Subroutine resource: not called CC=2 SCAR=17.9
Pod undocumented
96 0 my ( $self, $c, $filter_condition ) = @_;
97  
98 0 my $resources = $c->model('TestrunDB')->resultset('Resource')->search($filter_condition->{early}, { columns => [ qw/name/ ] });
99  
100 0 ▶ while ( my $resource = $resources->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $resource = $resources->next) 0 0 0
101 0 $c->stash->{overviews}{$resource->name} = '/tapper/testruns/resource/'.$resource->name;
102 }
103 0 $c->stash->{title} = "Tapper resources";
104 }
105  
106 0 ▶sub prepare_navi : Private
Subroutine prepare_navi: not called CC=1 SCAR=6.9
Pod undocumented
107 {
108 0 my ( $self, $c ) = @_;
109  
110 $c->stash->{navi}= [{
111 0 title => 'Overview of',
112 subnavi => [
113 {
114 title => 'Suites',
115 href => "/tapper/overview/suite/weeks/2",
116 },
117 {
118 title => 'Hosts',
119 href => "/tapper/overview/host/weeks/2",
120 },
121 ],
122  
123 },
124 {
125 title => 'Suites used in the last..',
126 subnavi => [
127 {
128 title => '1 week',
129 href => "/tapper/overview/suite/weeks/1",
130 },
131 {
132 title => '2 weeks',
133 href => "/tapper/overview/suite/weeks/2",
134 },
135 {
136 title => '6 weeks',
137 href => "/tapper/overview/suite/weeks/6",
138 },
139 {
140 title => '12 weeks',
141 href => "/tapper/overview/suite/weeks/12",
142 },
143 ],
144 },
145 {
146 title => 'Hosts used in the last..',
147 subnavi => [
148 {
149 title => '1 week',
150 href => "/tapper/overview/host/weeks/1",
151 },
152 {
153 title => '2 weeks',
154 href => "/tapper/overview/host/weeks/2",
155 },
156 {
157 title => '6 weeks',
158 href => "/tapper/overview/host/weeks/6",
159 },
160 {
161 title => '12 weeks',
162 href => "/tapper/overview/host/weeks/12",
163 },
164 ],
165  
166 },
167 {
168 title => 'All suites',
169 href => '/tapper/overview/suite/all',
170 }
171 ];
172 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
173  
174 13 1;
175  
176 __END__
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Rss.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Tapper/Testruns.pm »