sub (/robots.txt) { NOT_FOUND },
sub (/src/:job) {
- my $job = job_full $_{job};
+ my $job = db->select(jobs => '*', {id => $_{job}})->hash;
return NOT_FOUND if !$job;
my $isowner = remote_user && remote_user->{id} eq $job->{owner};
my $contest = $job->{contest} && contest_entry $job->{contest};
},
},
- sub (/st/:contest) { response st => 'Standings', standings($_{contest}), 10 },
+ sub (/st/:contest) {
+ my @pb = map { [$_->{id}, $_->{name}] } @{problem_list contest => $_{contest}};
+ response st => 'Standings', {problems => \@pb, st => standings $_{contest}}, 10
+ },
sub (/ed/:contest) {
- my $contest = contest_full $_{contest};
- forbid !$contest->{finished};
+ my $contest = db->select(contests => '*', {id => $_{contest}})->hash;
+ forbid time < $contest->{stop};
my $pblist = problem_list contest => $_{contest}, solution => 1;
- response ed => 'Editorial of ' . $contest->{name}, {%$pblist, editorial => $contest->{editorial}}
+ response ed => 'Editorial of ' . $contest->{name}, {pb => $pblist, editorial => $contest->{editorial}}
},
sub (/login) {
sub (/ct/:contest/log/st) { redirect "/st/$_{contest}" },
sub (/us/) { response us => 'Users', {us => user_list} },
- sub (/ct/ + ?:owner~) { response ct => 'Contests', contest_list(%_), 300 },
+ sub (/ct/ + ?:owner~) { response ct => 'Contests', {ct => contest_list(%_)}, 300 },
sub (/log/ + ?:contest~&:owner~&:page~&:problem~&:private~&:result~) {
forbid $_{private};
- response log => 'Job list', job_list(%_), 5
+ my ($jobs, $pageinfo) = job_list(%_);
+ response log => 'Job list', {log => $jobs, %$pageinfo}, 5
},
sub (/pb/ + ?:owner~&:contest~&:private~) {
forbid $_{private};
my $pending = $_{contest} && !contest_entry($_{contest})->{started};
forbid $pending;
- response pb => 'Problems', problem_list %_
+ response pb => 'Problems', {pb => problem_list %_}
},
sub (/us/:user) {
sub ftime ($) { POSIX::strftime '%c', localtime shift }
sub literal ($) {
my ($html) = @_;
- return unless $html;
+ return '' unless $html;
my $b = HTML::TreeBuilder->new;
$b->ignore_unknown(0);
$b->parse($html);
$tr->fclass('name')->namedlink($data->{id}, $data->{name});
$tr->fclass('owner')->namedlink($data->{owner}, $data->{owner_name});
};
+ for (@{$args{ct}}) {
+ my $state = $_->{finished} ? 'finished' : $_->{started} ? 'running' : 'pending';
+ push @{$args{$state} //= []}, $_;
+ }
$args{$_} ? $tree->fid($_)->find('tbody')->find('tr')->iter3($args{$_}, $iter) : $tree->fid($_)->detach for qw/running pending finished/;
}
$div->find('h2')->replace_content(ucfirst $data);
$div->find('tbody')->find('tr')->iter3($args{$data}, $titer);
};
+ push @{$args{$_->{level}} //= []}, $_ for @{$args{pb}};
$tree->fid('beginner')->iter3([grep {$args{$_}} qw/beginner easy medium hard/], $iter);
$tree->fid('open-alert')->detach unless $args{contest};
}
$div->set_child_content(class => 'solution', literal $data->{solution});
$div->fclass('problem')->namedlink($data->{id}, $data->{name});
};
- my @pb = map { @{$args{$_} // []} } qw/beginner easy medium hard/;
+ my @pb = sort { $a->{value} <=> $b->{value} } @{$args{pb}};
$tree->fclass('well')->iter3(\@pb, $iter);
}