blib/lib/Tapper/Reports/Web/Util/Report.pm

filter: Statementstmt 38.1% 24 / 63 Branchbran 4.5% 1 / 22 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 22.7% 28 / 123 CC 24 SCAR 58.3
CC
24
Cov
24%
prepare_simple_reportlist
370.0
BEGIN
1.0
BEGIN
1.0
CRAP 341.6
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Metareports.pm ↑ Summary blib/lib/Tapper/Reports/Web/Util/Testrun.pm »
1 package Tapper::Reports::Web::Util::Report;
2 17 our $AUTHORITY = 'cpan:TAPPER';
3 17 $Tapper::Reports::Web::Util::Report::VERSION = '5.0.17';
4 17 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use Tapper::Model 'model';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 extends 'Tapper::Reports::Web::Util';
8  
9 1 ▶sub prepare_simple_reportlist {
Subroutine prepare_simple_reportlist: called CC=24 SCAR=59.1
Pod undocumented
10  
11 1 my ( $self, $c, $reports ) = @_;
12  
13 # Mnemonic:
14 # rga = ReportGroup Arbitrary
15 # rgt = ReportGroup Testrun
16  
17 1 my $or_schema = model('TestrunDB');
18 1 my @all_reports;
19 my @reports;
20 1 my %rgt;
21 1 my %rga;
22 1 my %rgt_prims;
23 1 my %rga_prims;
24 1 ▶ while (my $report = $reports->next)
Branch: 1 branch
BranchTrueFalseTotal
if (my $report = $reports->next) 0 1 1
25 {
26 0 my %cols = $report->get_columns;
27 0 my $rga_id = $cols{rga_id};
28 0 my $rga_primary = $cols{rga_primary};
29 0 my $rgt_id = $cols{rgt_id};
30 0 my $rgt_primary = $cols{rgt_primary};
31 0 ▶ my $suite_name = $cols{suite_name} || 'unknownsuite';
Condition0%0/2
$cols{'suite_name'} || 'unknownsuite'
l!l
00
MC/DC0%0/1
$cols{'suite_name'} || 'unknownsuite'
$cols{'suite_name'}
Truth table0%0/2
A
A= $cols{'suite_name'}
Aresult
11
00
32 0 ▶ my $suite_id = $cols{suite_id} || '0';
Condition0%0/2
$cols{'suite_id'} || '0'
l!l
00
MC/DC0%0/1
$cols{'suite_id'} || '0'
$cols{'suite_id'}
Truth table0%0/2
A
A= $cols{'suite_id'}
Aresult
11
00
33 0 ▶ my $r = {
Branch: 1 branch
BranchTrueFalseTotal
$report->parse_errors ? : 0 0 0
Condition0%0/2
$report->machine_name || 'unknownmachine'
l!l
00
MC/DC0%0/1
$report->machine_name || 'unknownmachine'
$report->machine_name
Truth table0%0/2
A
A= $report->machine_name
Aresult
11
00
34 id => $report->id,
35 suite_name => $suite_name,
36 suite_id => $suite_id,
37 machine_name => $report->machine_name || 'unknownmachine',
38 created_at_ymd_hms => $report->created_at->ymd('-')." ".$report->created_at->hms(':'),
39 created_at_ymd_hm => sprintf("%s %02d:%02d",$report->created_at->ymd('-'), $report->created_at->hour, $report->created_at->minute),
40 created_at_ymd => $report->created_at->ymd('-'),
41 success_ratio => $report->success_ratio,
42 successgrade => $report->parse_errors ? 'ERROR' : $report->successgrade,
43 total => $report->total,
44 rga_id => $rga_id,
45 rga_primary => $rga_primary,
46 rgt_id => $rgt_id,
47 rgt_primary => $rgt_primary,
48 parse_errors => $report->parse_errors,
49 peerport => $report->peerport,
50 peeraddr => $report->peeraddr,
51 peerhost => $report->peerhost,
52 };
53  
54 # --- scheduling state ---
55 0 my $testrun_scheduling = $or_schema->resultset('TestrunScheduling')->search({testrun_id => $rgt_id}, {rows => 1})->first;
56 0 ▶ $r->{testrunscheduling_status} = $testrun_scheduling->status if $testrun_scheduling;
Branch: 1 branch
BranchTrueFalseTotal
if $testrun_scheduling 0 0 0
57  
58 # --- arbitrary ---
59 0 ▶ if ($rga_id and $rga_primary)
Branch: 1 branch
BranchTrueFalseTotal
if ($rga_id and $rga_primary) 0 0 0
Condition0%0/3
$rga_id and $rga_primary
!ll&&!rl&&r
000
MC/DC0%0/2
$rga_id and $rga_primary
$rga_id $rga_primary
Truth table0%0/3
A and B
A= $rga_idB= $rga_primary
ABresult
0X0
100
111
60 {
61 0 $r->{owner} = $report->reportgrouparbitrary->owner;
62 0 push @reports, $r;
63 0 $rga_prims{$rga_id} = 1;
64 }
65 0 ▶ if ($rga_id and not $rga_primary)
Branch: 1 branch
BranchTrueFalseTotal
if ($rga_id and not $rga_primary) 0 0 0
Condition0%0/3
$rga_id and not $rga_primary
!ll&&!rl&&r
000
MC/DC0%0/2
$rga_id and not $rga_primary
$rga_id not $rga_primary
Truth table0%0/3
A and not(B)
A= $rga_idB= not $rga_primary
ABresult
0X0
100
111
66 {
67 0 push @{$rga{$rga_id}}, $r;
68 }
69  
70 # --- testrun ---
71 0 ▶ if ($rgt_id and $rgt_primary)
Branch: 1 branch
BranchTrueFalseTotal
if ($rgt_id and $rgt_primary) 0 0 0
Condition0%0/3
$rgt_id and $rgt_primary
!ll&&!rl&&r
000
MC/DC0%0/2
$rgt_id and $rgt_primary
$rgt_id $rgt_primary
Truth table0%0/3
A and B
A= $rgt_idB= $rgt_primary
ABresult
0X0
100
111
72 {
73 0 $r->{owner} = $report->reportgrouptestrun->owner;
74 0 push @reports, $r;
75 0 $rgt_prims{$rgt_id} = 1;
76 }
77 0 ▶ if ($rgt_id and not $rgt_primary)
Branch: 1 branch
BranchTrueFalseTotal
if ($rgt_id and not $rgt_primary) 0 0 0
Condition0%0/3
$rgt_id and not $rgt_primary
!ll&&!rl&&r
000
MC/DC0%0/2
$rgt_id and not $rgt_primary
$rgt_id not $rgt_primary
Truth table0%0/3
A and not(B)
A= $rgt_idB= not $rgt_primary
ABresult
0X0
100
111
78 {
79 0 push @{$rgt{$rgt_id}}, $r;
80 }
81  
82 # --- none ---
83 0 ▶ if (! $rga_id and ! $rgt_id)
Branch: 1 branch
BranchTrueFalseTotal
unless ($rga_id or $rgt_id) 0 0 0
Condition0%0/3
$rga_id or $rgt_id
l!l&&r!l&&!r
000
MC/DC0%0/2
$rga_id or $rgt_id
$rga_id $rgt_id
Truth table0%0/3
A or B
A= $rga_idB= $rgt_id
ABresult
1X1
011
000
84 {
85 0 push @reports, $r;
86 }
87  
88 0 push @all_reports, $r; # for easier overall stats
89 }
90  
91 # Find groups without primary report
92 1 my @rga_noprim;
93 my @rgt_noprim;
94 1 foreach (keys %rga) {
95 0 ▶ push @rga_noprim, $_ unless $rga_prims{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $rga_prims{$_} 0 0 0
96 }
97 1 foreach (keys %rgt) {
98 0 ▶ push @rgt_noprim, $_ unless $rgt_prims{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $rgt_prims{$_} 0 0 0
99 }
100 # Pull out latest one and put into @reports as primary
101 1 foreach (@rga_noprim) {
102 0 my $rga_primary = pop @{$rga{$_}};
103 0 $rga_primary->{rga_primary} = 1;
104 0 push @reports, $rga_primary;
105 }
106 1 foreach (@rgt_noprim) {
107 0 my $rgt_primary = pop @{$rgt{$_}};
108 0 $rgt_primary->{rgt_primary} = 1;
109  
110 0 my $testrun = model('TestrunDB')->resultset('Testrun')->find($_);
111 0 ▶ $rgt_primary->{owner} = $testrun->owner->login if $testrun;
Branch: 1 branch
BranchTrueFalseTotal
if $testrun 0 0 0
112  
113 0 push @reports, $rgt_primary;
114 }
115  
116 return {
117 1 all_reports => \@all_reports,
118 reports => \@reports,
119 rga => \%rga,
120 rgt => \%rgt,
121 };
122 }
123  
124  
125 17 1;
126  
127 __END__
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Metareports.pm ↑ Summary blib/lib/Tapper/Reports/Web/Util/Testrun.pm »