Arepa/Web/Queue.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 67 CC 3 SCAR 12.8
CC
3
Cov
0%
build_log
6.0
requeue
6.0
BEGIN
2.0
CRAP 3.6
1 package Arepa::Web::Queue;
2  
3 use strict;
4 use warnings;
5  
6 use base 'Arepa::Web::Base';
7  
8 use English qw(-no_match_vars);
9 use Encode;
10 use Arepa::PackageDb;
11  
12 sub build_log {
13 my ($self) = @_;
14  
15 # Force it to be a number
16 my $request_id = 0 + $self->param('id');
17 my $pdb = Arepa::PackageDb->new($self->config->get_key('package_db'));
18 eval {
19 $pdb->get_compilation_request_by_id($request_id);
20 };
21 if ($EVAL_ERROR) {
22 return $self->show_view({errors => [{output => "No such compilation " .
23 "request: '$request_id'"}]},
24 template => 'error');
25 }
26 else {
27 my $build_log_path =
28 File::Spec->catfile($self->config->get_key('dir:build_logs'),
29 $request_id);
30 open F, $build_log_path or do {
31 return $self->show_view(
32 {errors => [{output => "Can't read build log for " .
33 "compilation request '$request_id' from " .
34 "'$build_log_path'"}]},
35 template => 'error');
36 };
37 my $build_log_contents = join("", <F>);
38 close F;
39 $self->show_view({log => decode('utf-8', $build_log_contents)});
40 }
41 }
42  
43 sub requeue {
44 my ($self) = @_;
45  
46 $self->_only_if_admin(sub {
47 # Force it to be a number
48 my $request_id = 0 + $self->param('id');
49 my $pdb = Arepa::PackageDb->new($self->config->get_key('package_db'));
50 eval {
51 $pdb->get_compilation_request_by_id($request_id);
52 };
53 if ($EVAL_ERROR) {
54 return $self->show_view('error.tmpl',
55 {errors => [{output => "No such compilation request: '$request_id'"}]});
56 }
57 else {
58 $pdb->mark_compilation_pending($request_id);
59 $self->redirect_to('home');
60 }
61 });
62 }
63  
64 1;