]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
f4d961e2dd12b7c586a1baf0a1a302669c77ef75
1 package Gruntmaster
::Page
::St
;
6 use parent qw
/Exporter/;
7 our @EXPORT_OK = qw
/generate/;
8 our $VERSION = '0.001';
10 use constant TITLE
=> 'Standings';
13 use HTML
::Template
::Compiled
;
15 use List
::Util qw
/sum/;
16 use POSIX qw
/strftime/;
17 use YAML
::Any qw
/LoadFile/;
18 use Gruntmaster
::Page
::Common qw
/header footer/;
24 <tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
26 <tmpl_loop st><tr><td><tmpl_var user>
27 <tmpl_loop scores><td><tmpl_var _>
28 </tmpl_loop><td><tmpl_var score>
34 $templates{$_} = header
($_, TITLE
) . $templates{$_} for keys %templates;
35 $templates{$_} .= footer
$_ for keys %templates;
38 my ($path, $lang) = @_;
39 $path =~ s
,/st\
.html
$,,;
40 my $template = $templates{$lang};
41 my $htc = HTML
::Template
::Compiled
->new(scalarref
=> \
$template);
42 IO
::File
->new(">$path/meta.yml")->close unless -f
"$path/meta.yml";
43 flock my $metafh = IO
::File
->new("<$path/meta.yml"), LOCK_SH
;
44 my $meta = LoadFile
"$path/meta.yml";
45 my @problems = sort grep { /^\w+$/ } map { s
,.*/,,r } <$path/../pb/*>;
47 for (1 .. $meta->{last}) {
48 my $meta = LoadFile
"$path/$_/meta.yml";
49 if ($meta->{result_text
} =~ m/^(\d+)/) {
50 $scores{$meta->{user
}}{$meta->{problem
}} = $1;
52 $scores{$meta->{user
}}{$meta->{problem
}} = $meta->{result
} ?
0 : 100;
56 my @st = sort { $b->{score
} <=> $a->{score
} } map {
60 score
=> sum
(values $scores{$user}),
61 scores
=> [map { $scores{$user}{$_} // '-'} @problems],
64 $htc->param(problems
=> \
@problems);
65 $htc->param(st
=> \
@st);
This page took 0.053603 seconds and 4 git commands to generate.