From: Marius Gavrilescu Date: Sat, 8 Feb 2014 22:55:59 +0000 (+0200) Subject: Add ranks to standings and reduce warnings X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=cb98abf4bd74c0f9646d264afb297505eb85f611;p=gruntmaster-page.git Add ranks to standings and reduce warnings --- diff --git a/lib/Gruntmaster/Page/St.pm b/lib/Gruntmaster/Page/St.pm index 099c193..2186fea 100644 --- a/lib/Gruntmaster/Page/St.pm +++ b/lib/Gruntmaster/Page/St.pm @@ -46,8 +46,8 @@ sub _generate{ if ($Gruntmaster::Data::contest) { $tries{job_user()}{job_problem()}++; $scores{job_user()}{job_problem()} = job_result() ? 0 : calc_score (job_user(), job_problem(), job_date(), $tries{job_user()}{job_problem()}, $totaltime) if job_date() > $start; - } else { - if (job_result_text =~ m/^(\scores+)/) { + } elsif (defined job_user && defined job_problem && defined job_result) { + if (defined job_result_text && job_result_text =~ m/^(\scores+)/) { $scores{job_user()}{job_problem()} = $ct; } else { $scores{job_user()}{job_problem()} = job_result() ? 0 : 100; @@ -55,7 +55,7 @@ sub _generate{ } } - my @st = sort { $b->{score} <=> $a->{score} } map { + my @st = sort { $b->{score} <=> $a->{score} or $a->{user} cmp $b->{user}} map { my $user = $_; +{ user => $user, @@ -64,6 +64,9 @@ sub _generate{ problems => $Gruntmaster::Data::contest, } } keys %scores; + + $st[0]->{rank} = 1; + $st[$_]->{rank} = $st[$_ - 1]->{rank} + ($st[$_]->{score} < $st[$_ - 1]->{score}) for 1 .. $#st; $htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest; $htc->param(st => \@st); } diff --git a/tmpl/st.en b/tmpl/st.en index 1e4c8ec..0c9893b 100644 --- a/tmpl/st.en +++ b/tmpl/st.en @@ -1,11 +1,11 @@ - -
UsernameTotal -
UsernameScore +
RankUsernameTotal +
RankUsernameScore
+