| 1 | package Tapper::CLI::Schema; | ||||||||||
| 2 | 72 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||
| 3 | 72 | $Tapper::CLI::Schema::VERSION = '5.0.8'; | |||||||||
| 4 | 72 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 72 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 72 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | sub zipfiles | ||||||||||
| 10 | 0 | ▶ | { | ||||||||
|
Subroutine
zipfiles: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 11 | 0 | my ($c) = @_; | |||||||||
| 12 | 0 | $c->getopt( 'quiet|q', 'help|?' ); | |||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | if ($c->options->{help} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 0 | say STDERR "Usage: $0 schema-zipfiles [ --quiet ]"; | |||||||||
| 16 | 0 | say STDERR "\n Optional arguments:"; | |||||||||
| 17 | 0 | say STDERR "\t--quiet\tPrint a dot instead of the file name of the updated file"; | |||||||||
| 18 | 0 | say STDERR "\t--help\t\tprint this help message and exit"; | |||||||||
| 19 | 0 | exit -1; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 0 | require Compress::Bzip2; | |||||||||
| 23 | 0 | require Tapper::Model; | |||||||||
| 24 | 0 | my $uncompressed_files = Tapper::Model::model('TestrunDB')->resultset('ReportFile')->search({is_compressed => 0}); | |||||||||
| 25 | 0 | ▶ | while (my $file = $uncompressed_files->next) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $compressed; | |||||||||
| 27 | 0 | eval { $compressed = memBzip( $file->filecontent) }; | |||||||||
| 28 | 0 | ▶ | if (defined $compressed) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | ▶ | print( $c->options->{quiet} ? '.' : "COMPRESS ".$file->report_id.":".$file->id.":".$file->filename."\n" ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | $file->set_column(filecontent => $compressed); | |||||||||
| 31 | 0 | $file->is_compressed(1); | |||||||||
| 32 | 0 | $file->update(); | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | sub setup | ||||||||||
| 40 | 71 | ▶ | { | ||||||||
|
Subroutine
setup: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 41 | 71 | my ($c) = @_; | |||||||||
| 42 | 71 | $c->register('schema-zipfiles', \&zipfiles, 'Compress all uncompressed files uploaded to reports framework'); | |||||||||
| 43 | 71 | ▶ | if ($c->can('group_commands')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | $c->group_commands('Schema commands', 'schema-zipfiles'); | |||||||||
| 45 | } | ||||||||||
| 46 | 71 | return; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 72 | 1; # End of Tapper::CLI | |||||||||
| 50 | |||||||||||
| 51 | __END__ | ||||||||||