]> iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Log/Entry.pm
Use Redis and reindent code
[gruntmaster-page.git] / lib / Gruntmaster / Page / Log / Entry.pm
1 package Gruntmaster::Page::Log::Entry;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use parent qw/Exporter/;
7 our @EXPORT_OK = qw/generate/;
8 our $VERSION = '0.001';
9
10 use constant TITLE => 'Job <tmpl_var id>';
11
12 use HTML::Template::Compiled;
13 use POSIX qw/strftime/;
14 use Gruntmaster::Page::Common qw/header footer/;
15 use Gruntmaster::Data qw/job_results/;
16
17 my %templates = (
18 en => <<'HTML',
19 <table border>
20 <thead>
21 <tr><th>Test number<th>Result<th>Time
22 <tbody>
23 <tmpl_loop tests><tr><td><tmpl_var id><td class="r<tmpl_var result>"><tmpl_var result_text><td><tmpl_var time>
24 </tmpl_loop>
25 </table>
26 HTML
27 );
28
29 $templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates;
30 $templates{$_} .= footer $_ for keys %templates;
31
32 sub generate{
33 $_[0] =~ m,^(?:ct/([^/]+)/)?log/([^/]+)/index\.html$,;
34 local $Gruntmaster::Data::contest = $1;
35 my $id = $2;
36
37 my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
38
39 my @tests = map {
40 $_->{time} = sprintf "%.4fs", $_->{time};
41 $_
42 } @{job_results $id};
43
44 $htc->param(id => $id);
45 $htc->param(tests => \@tests);
46 $htc->output
47 }
48
49 1
This page took 0.044311 seconds and 5 git commands to generate.