| 1 | package Tapper::Schema::TestrunDB::Result::ReportgroupTestrunStats; | ||||||||||||
| 2 | 10 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||
| 3 | 10 | $Tapper::Schema::TestrunDB::Result::ReportgroupTestrunStats::VERSION = '5.0.12'; | |||||||||||
| 4 | # ABSTRACT: Tapper - Containing additional aggregated data to testruns | ||||||||||||
| 5 | |||||||||||||
| 6 | 10 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 10 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 10 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 10 | ▶ | use parent 'DBIx::Class'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 10 | __PACKAGE__->load_components('Core'); | |||||||||||
| 13 | 10 | __PACKAGE__->table('reportgrouptestrunstats'); | |||||||||||
| 14 | 10 | __PACKAGE__->add_columns( | |||||||||||
| 15 | 'testrun_id', { | ||||||||||||
| 16 | data_type => 'INT', | ||||||||||||
| 17 | default_value => undef, | ||||||||||||
| 18 | is_nullable => 0, | ||||||||||||
| 19 | size => 11, | ||||||||||||
| 20 | is_foreign_key => 1, | ||||||||||||
| 21 | }, | ||||||||||||
| 22 | 'total', { | ||||||||||||
| 23 | data_type => 'INT', | ||||||||||||
| 24 | default_value => undef, | ||||||||||||
| 25 | is_nullable => 1, | ||||||||||||
| 26 | size => 10, | ||||||||||||
| 27 | }, | ||||||||||||
| 28 | 'failed', { | ||||||||||||
| 29 | data_type => 'INT', | ||||||||||||
| 30 | default_value => undef, | ||||||||||||
| 31 | is_nullable => 1, | ||||||||||||
| 32 | size => 10, | ||||||||||||
| 33 | }, | ||||||||||||
| 34 | 'passed', { | ||||||||||||
| 35 | data_type => 'INT', | ||||||||||||
| 36 | default_value => undef, | ||||||||||||
| 37 | is_nullable => 1, | ||||||||||||
| 38 | size => 10, | ||||||||||||
| 39 | }, | ||||||||||||
| 40 | 'parse_errors', { | ||||||||||||
| 41 | data_type => 'INT', | ||||||||||||
| 42 | default_value => undef, | ||||||||||||
| 43 | is_nullable => 1, | ||||||||||||
| 44 | size => 10, | ||||||||||||
| 45 | }, | ||||||||||||
| 46 | 'skipped', { | ||||||||||||
| 47 | data_type => 'INT', | ||||||||||||
| 48 | default_value => undef, | ||||||||||||
| 49 | is_nullable => 1, | ||||||||||||
| 50 | size => 10, | ||||||||||||
| 51 | }, | ||||||||||||
| 52 | 'todo', { | ||||||||||||
| 53 | data_type => 'INT', | ||||||||||||
| 54 | default_value => undef, | ||||||||||||
| 55 | is_nullable => 1, | ||||||||||||
| 56 | size => 10, | ||||||||||||
| 57 | }, | ||||||||||||
| 58 | 'todo_passed', { | ||||||||||||
| 59 | data_type => 'INT', | ||||||||||||
| 60 | default_value => undef, | ||||||||||||
| 61 | is_nullable => 1, | ||||||||||||
| 62 | size => 10, | ||||||||||||
| 63 | }, | ||||||||||||
| 64 | 'success_ratio', { | ||||||||||||
| 65 | data_type => 'VARCHAR', | ||||||||||||
| 66 | default_value => undef, | ||||||||||||
| 67 | is_nullable => 1, | ||||||||||||
| 68 | size => 20, | ||||||||||||
| 69 | }, | ||||||||||||
| 70 | ); | ||||||||||||
| 71 | |||||||||||||
| 72 | 10 | __PACKAGE__->set_primary_key(qw/testrun_id/); | |||||||||||
| 73 | 10 | __PACKAGE__->has_many( | |||||||||||
| 74 | reportgrouptestruns => 'Tapper::Schema::TestrunDB::Result::ReportgroupTestrun', | ||||||||||||
| 75 | { 'foreign.testrun_id' => 'self.testrun_id' }, | ||||||||||||
| 76 | { cascade_delete => 0, cascade_copy => 0 }, | ||||||||||||
| 77 | ); | ||||||||||||
| 78 | 10 | __PACKAGE__->has_one( | |||||||||||
| 79 | testrun => 'Tapper::Schema::TestrunDB::Result::Testrun', | ||||||||||||
| 80 | { 'foreign.id' => 'self.testrun_id' }, | ||||||||||||
| 81 | ); | ||||||||||||
| 82 | |||||||||||||
| 83 | |||||||||||||
| 84 | |||||||||||||
| 85 | 1 | ▶ | sub groupreports { | ||||||||||
|
Subroutine
groupreports: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 86 | 1 | my ($self) = @_; | |||||||||||
| 87 | |||||||||||||
| 88 | 1 | $self->reportgrouptestruns->groupreports; | |||||||||||
| 89 | } | ||||||||||||
| 90 | |||||||||||||
| 91 | |||||||||||||
| 92 | sub _success_ratio | ||||||||||||
| 93 | 0 | ▶ | { | ||||||||||
|
Subroutine
_success_ratio: not called CC=2 SCAR=17.9
| |||||||||||||
| 94 | 0 | my ($self) = @_; | |||||||||||
| 95 | |||||||||||||
| 96 | 0 | ▶ | my $ratio = sprintf("%02.2f", $self->total ? ($self->passed / ($self->total + $self->parse_errors) * 100) : 100 ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | 0 | return $ratio; | |||||||||||
| 98 | } | ||||||||||||
| 99 | |||||||||||||
| 100 | |||||||||||||
| 101 | sub success_word | ||||||||||||
| 102 | 0 | ▶ | { | ||||||||||
|
Subroutine
success_word: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 103 | 0 | my ($self) = @_; | |||||||||||
| 104 | 0 | ▶ | $self->success_ratio == 100 ? 'pass' : 'fail'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | |||||||||||||
| 108 | |||||||||||||
| 109 | sub update_failed_passed | ||||||||||||
| 110 | 0 | ▶ | { | ||||||||||
|
Subroutine
update_failed_passed: not called CC=5 SCAR=30.9
Pod
documented
| |||||||||||||
| 111 | 0 | my ($self) = @_; | |||||||||||
| 112 | |||||||||||||
| 113 | 0 | my $failed = 0; | |||||||||||
| 114 | 0 | my $passed = 0; | |||||||||||
| 115 | 0 | my $total = 0; | |||||||||||
| 116 | 0 | my $parse_errors = 0; | |||||||||||
| 117 | 0 | my $skipped = 0; | |||||||||||
| 118 | 0 | my $todo = 0; | |||||||||||
| 119 | 0 | my $todo_passed = 0; | |||||||||||
| 120 | 0 | my $wait = 0; | |||||||||||
| 121 | 0 | my $exit = 0; | |||||||||||
| 122 | |||||||||||||
| 123 | 0 | my $reports_rs = $self->groupreports; | |||||||||||
| 124 | 10 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 125 | 0 | my %sums = (); | |||||||||||
| 126 | 0 | my @stat_fields = (qw/failed passed total parse_errors skipped todo todo_passed /); # no "exit" or "wait", that would create wrong SQL | |||||||||||
| 127 | 0 | ▶ | while (my $r = $reports_rs->next) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 128 | 0 | ▶ | $sums{$_} += ($r->$_ // 0) foreach @stat_fields; | ||||||||||
|
Condition0%0/2
$r->$_ // 0
MC/DC0%0/1
$r->$_ // 0
$r->$_
Truth table0%0/2
A
A= $r->$_
| |||||||||||||
| 129 | } | ||||||||||||
| 130 | 0 | $self->$_($sums{$_}) foreach @stat_fields; | |||||||||||
| 131 | 0 | $self->success_ratio( $self->_success_ratio ); | |||||||||||
| 132 | 0 | return $self; | |||||||||||
| 133 | } | ||||||||||||
| 134 | |||||||||||||
| 135 | 10 | 1; | |||||||||||
| 136 | |||||||||||||
| 137 | __END__ | ||||||||||||