]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/St.pm
General standings should not list problems
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / St.pm
index e5b418d26a7844767e06c053b8d5ac05175720dd..b50490c00f3e31d6d22382c45b5003148373d6cc 100644 (file)
@@ -3,40 +3,35 @@ package Gruntmaster::Page::St;
 use 5.014000;
 use strict;
 use warnings;
-use parent qw/Exporter/;
-our @EXPORT_OK = qw/generate/;
+use Gruntmaster::Page::Base st => 'Standings';
+our @ISA = qw/Gruntmaster::Page::Base/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Standings';
-
-use HTML::Template::Compiled;
-use List::Util qw/sum/;
-use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/header footer/;
-use Gruntmaster::Data qw/problems jobcard job_result_text job_result job_problem job_user/;
-
-my %templates = (
+use constant TEMPLATES => {
        en => <<'HTML',
 <table border>
 <thead>
-<tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
+<tmpl_if problems><tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
+<tmpl_else><tr><th>Username<th>Score
+</tmpl_if>
+
 <tbody>
 <tmpl_loop st><tr><td><tmpl_var user>
-<tmpl_loop scores><td><tmpl_var _>
-</tmpl_loop><td><tmpl_var score>
+<tmpl_if problems><tmpl_loop scores><td><tmpl_var _>
+</tmpl_loop></tmpl_if><td><tmpl_var score>
 </tmpl_loop>
 </table>
 HTML
-);
+};
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+sub _generate{
+       my ($self, $htc, $path, $lang) = @_;
 
-sub generate{
-       local $Gruntmaster::Data::contest = ($_[0] =~ m,^ct/([^/]+)/,)[0];
-       my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
+       $path =~ m,^(?:ct/([^/]+)/)?,;
+       local $Gruntmaster::Data::contest = $1;
 
-       my @problems = sort problems;
+       my @problems = problems;
+       @problems = sort @problems;
        my %scores;
        for (1 .. jobcard) {
                if (job_result_text =~ m/^(\d+)/) {
@@ -54,9 +49,8 @@ sub generate{
                        scores => [map { $scores{$user}{$_} // '-'} @problems],
                }
        } keys %scores;
-       $htc->param(problems => \@problems);
+       $htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest;
        $htc->param(st => \@st);
-       $htc->output
 }
 
 1
This page took 0.025736 seconds and 4 git commands to generate.