File Coverage

blib/lib/Tapper/Schema/TestrunDB/Result/ReportFile.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Tapper::Schema::TestrunDB::Result::ReportFile;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Schema::TestrunDB::Result::ReportFile::VERSION = '5.0.11';
4             # ABSTRACT: Tapper - Containg files attached to reports
5              
6 7     7   3621 use strict;
  7         16  
  7         180  
7 7     7   29 use warnings;
  7         14  
  7         159  
8              
9 7     7   29 use parent 'DBIx::Class';
  7         16  
  7         35  
10 7     7   3325 use Compress::Bzip2;
  7         52207  
  7         3606  
11              
12             __PACKAGE__->load_components(qw/FilterColumn InflateColumn::DateTime TimeStamp Core/);
13             __PACKAGE__->table("reportfile");
14             __PACKAGE__->add_columns
15             (
16             "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, },
17             "report_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
18             "filename", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
19             "contenttype", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
20             "filecontent", { data_type => "LONGBLOB", default_value => "", is_nullable => 0, },
21             "is_compressed", { data_type => "INT", default_value => 0, is_nullable => 0, },
22             "created_at", { data_type => "DATETIME", default_value => undef, is_nullable => 0, set_on_create => 1, },
23             "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 0, set_on_create => 1, set_on_update => 1, },
24             );
25              
26             __PACKAGE__->set_primary_key("id");
27             __PACKAGE__->filter_column('filecontent', {
28             filter_from_storage => sub { my ($row, $element) = @_;
29             my $uncompressed;
30             if ($row->is_compressed) {
31             eval { $uncompressed = memBunzip( $element ) };
32             return $uncompressed if !$@ && $uncompressed;
33             }
34             return $element;
35             },
36             filter_to_storage => sub { my ($row, $element) = @_;
37             if ($element) {
38             my $compressed;
39             eval {
40             $compressed = memBzip( $element );
41             };
42             if (!$@ and $compressed) {
43             $row->is_compressed( 1 );
44             return $compressed;
45             } else {
46             $row->is_compressed( 0 );
47             return $element;
48             }
49             } else {
50             $row->is_compressed( 0 );
51             return $element;
52             }
53             },
54             }
55             );
56             __PACKAGE__->belongs_to ( report => 'Tapper::Schema::TestrunDB::Result::Report', { 'foreign.id' => 'self.report_id' });
57              
58             1;
59              
60             __END__
61              
62             =pod
63              
64             =encoding UTF-8
65              
66             =head1 NAME
67              
68             Tapper::Schema::TestrunDB::Result::ReportFile - Tapper - Containg files attached to reports
69              
70             =head1 AUTHORS
71              
72             =over 4
73              
74             =item *
75              
76             AMD OSRC Tapper Team <tapper@amd64.org>
77              
78             =item *
79              
80             Tapper Team <tapper-ops@amazon.com>
81              
82             =back
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             This software is Copyright (c) 2019 by Advanced Micro Devices, Inc..
87              
88             This is free software, licensed under:
89              
90             The (two-clause) FreeBSD License
91              
92             =cut