File Coverage

blib/lib/Tapper/Schema/TestrunDB/Result/ScenarioElement.pm
Criterion Covered Total %
statement 11 14 78.5
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 16 22 72.7


line stmt bran cond sub pod time code
1             package Tapper::Schema::TestrunDB::Result::ScenarioElement;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Schema::TestrunDB::Result::ScenarioElement::VERSION = '5.0.9';
4             # ABSTRACT: Tapper - Containing relations between scenarios and testrun_ids
5              
6 7     7   3134 use 5.010;
  7         16  
7 7     7   23 use strict;
  7         9  
  7         115  
8 7     7   20 use warnings;
  7         7  
  7         151  
9              
10 7     7   19 use parent 'DBIx::Class';
  7         5  
  7         30  
11              
12             __PACKAGE__->load_components("InflateColumn::Object::Enum", "Core");
13             __PACKAGE__->table("scenario_element");
14             __PACKAGE__->add_columns
15             (
16             "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, },
17             "testrun_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
18             "scenario_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
19             "is_fitted", { data_type => "INT", default_value => 0, is_nullable => 0, size => 1, },
20             );
21              
22             __PACKAGE__->set_primary_key(qw/id/);
23              
24             (my $basepkg = __PACKAGE__) =~ s/::\w+$//;
25              
26             __PACKAGE__->belongs_to( testrun => "${basepkg}::Testrun", { 'foreign.id' => 'self.testrun_id' });
27             __PACKAGE__->belongs_to( scenario => "${basepkg}::Scenario", { 'foreign.id' => 'self.scenario_id' });
28             __PACKAGE__->has_many ( peer_elements => "${basepkg}::ScenarioElement", { 'foreign.scenario_id' => 'self.scenario_id' });
29              
30              
31             sub peers_need_fitting
32             {
33 0     0 1   my ($self) = @_;
34 0 0         return 0 if $self->scenario->type ne 'interdep';
35 0           return $self->peer_elements->search({is_fitted => { '!=' => 1,}})->count;
36             }
37              
38             1;
39              
40             __END__
41              
42             =pod
43              
44             =encoding UTF-8
45              
46             =head1 NAME
47              
48             Tapper::Schema::TestrunDB::Result::ScenarioElement - Tapper - Containing relations between scenarios and testrun_ids
49              
50             =head2 peers_need_fitting
51              
52             Count how many elements of this scenario do not have is_fitted already
53             set. This count may include $self.
54              
55             @return int - number of unfitted elements in same scenario
56              
57             =head1 AUTHORS
58              
59             =over 4
60              
61             =item *
62              
63             AMD OSRC Tapper Team <tapper@amd64.org>
64              
65             =item *
66              
67             Tapper Team <tapper-ops@amazon.com>
68              
69             =back
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is Copyright (c) 2017 by Advanced Micro Devices, Inc..
74              
75             This is free software, licensed under:
76              
77             The (two-clause) FreeBSD License
78              
79             =cut