File Coverage

blib/lib/Tapper/Schema/TestrunDB/Result/ReportgroupTestrun.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Tapper::Schema::TestrunDB::Result::ReportgroupTestrun;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Schema::TestrunDB::Result::ReportgroupTestrun::VERSION = '5.0.9';
4             # ABSTRACT: Tapper - Containing relations between testruns and reports
5              
6 7     7   2953 use 5.010;
  7         16  
7 7     7   25 use strict;
  7         9  
  7         105  
8 7     7   22 use warnings;
  7         7  
  7         147  
9              
10 7     7   21 use parent 'DBIx::Class';
  7         11  
  7         26  
11              
12             __PACKAGE__->load_components("Core");
13             __PACKAGE__->table("reportgrouptestrun");
14             __PACKAGE__->add_columns
15             (
16             "testrun_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
17             "report_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
18             "primaryreport", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, },
19             "owner", { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 255, },
20             );
21              
22             __PACKAGE__->set_primary_key(qw/testrun_id report_id/);
23              
24             __PACKAGE__->might_have ( reportgrouptestrunstats => 'Tapper::Schema::TestrunDB::Result::ReportgroupTestrunStats', { 'foreign.testrun_id' => 'self.testrun_id' }, { is_foreign_key_constraint => 0 } );
25             __PACKAGE__->belongs_to ( report => 'Tapper::Schema::TestrunDB::Result::Report', { 'foreign.id' => 'self.report_id' } );
26              
27             # -------------------- methods on results --------------------
28              
29              
30             sub groupreports {
31 3     3 1 11400 my ($self) = @_;
32              
33 3         3 my @report_ids;
34 3         17 my $rg = $self->result_source->schema->resultset('ReportgroupTestrun')->search({ testrun_id => $self->testrun_id });
35 3         1123 while (my $rg_entry = $rg->next) {
36 9         4418 push @report_ids, $rg_entry->report_id;
37             }
38 3         180 return $self->result_source->schema->resultset('Report')->search({ id => [ -or => [ @report_ids ] ] });
39             }
40              
41              
42             sub sqlt_deploy_hook
43             {
44 7     7 1 2724 my ($self, $sqlt_table) = @_;
45 7         37 $sqlt_table->add_index(name => 'reportgrouptestrun_idx_report_id', fields => ['report_id']);
46             }
47              
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Tapper::Schema::TestrunDB::Result::ReportgroupTestrun - Tapper - Containing relations between testruns and reports
59              
60             =head2 groupreports
61              
62             Return group of all reports belonging to this same testrun.
63              
64             =head2 sqlt_deploy_hook
65              
66             Add useful indexes at deploy time.
67              
68             =head1 AUTHORS
69              
70             =over 4
71              
72             =item *
73              
74             AMD OSRC Tapper Team <tapper@amd64.org>
75              
76             =item *
77              
78             Tapper Team <tapper-ops@amazon.com>
79              
80             =back
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is Copyright (c) 2017 by Advanced Micro Devices, Inc..
85              
86             This is free software, licensed under:
87              
88             The (two-clause) FreeBSD License
89              
90             =cut