]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Log/Entry.pm
Use Redis and reindent code
[gruntmaster-page.git] / lib / Gruntmaster / Page / Log / Entry.pm
index e849876d2a67a32f9abe138457c63d4242e652a8..309660a3065155f55f701790a18431c6b78e7c80 100644 (file)
@@ -9,15 +9,13 @@ our $VERSION = '0.001';
 
 use constant TITLE => 'Job <tmpl_var id>';
 
-use Fcntl qw/:flock/;
 use HTML::Template::Compiled;
-use IO::File;
 use POSIX qw/strftime/;
-use YAML::Any qw/LoadFile/;
 use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Data qw/job_results/;
 
 my %templates = (
-  en => <<'HTML',
+       en => <<'HTML',
 <table border>
 <thead>
 <tr><th>Test number<th>Result<th>Time
@@ -32,23 +30,20 @@ $templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
 $templates{$_} .= footer $_ for keys %templates;
 
 sub generate{
-  my ($path, $lang) = @_;
-  my $id = ($path =~ m,log/(.*)/index,)[0];
-  $path =~ s,/index\.html,,;
-  my $template = $templates{$lang};
-
-  my $htc = HTML::Template::Compiled->new(scalarref => \$template);
-  flock my $metafh = IO::File->new("<$path/meta.yml"), LOCK_SH;
-  my $meta = LoadFile "$path/meta.yml";
-
-  my @tests = map {
-       $_->{time} = sprintf "%.4fs", $_->{time};
-       $_
-  } @{$meta->{results}};
-
-  $htc->param(id => $id);
-  $htc->param(tests => \@tests);
-  $htc->output
+       $_[0] =~ m,^(?:ct/([^/]+)/)?log/([^/]+)/index\.html$,;
+       local $Gruntmaster::Data::contest = $1;
+       my $id = $2;
+
+       my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+
+       my @tests = map {
+               $_->{time} = sprintf "%.4fs", $_->{time};
+               $_
+       } @{job_results $id};
+
+       $htc->param(id => $id);
+       $htc->param(tests => \@tests);
+       $htc->output
 }
 
 1
This page took 0.025586 seconds and 4 git commands to generate.