]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data.pm
Set JOBS_PER_PAGE to 50
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index e3b56f43adf892284f04c0f7842384907f06ac2e..50dcfd57d1a407e8da7611515b3691fe66ae0b4f 100644 (file)
@@ -28,7 +28,7 @@ use Sub::Name qw/subname/;
 use constant CONTEST_PUBLIC_COLUMNS => [qw/id name description start stop owner/];
 use constant PROBLEM_PUBLIC_COLUMNS => [qw/id author writer level name owner private timeout olimit value/];
 use constant USER_PUBLIC_COLUMNS => [qw/id admin name town university country level/];
-use constant JOBS_PER_PAGE => 10;
+use constant JOBS_PER_PAGE => 50;
 
 sub dynsub{
        our ($name, $sub) = @_;
@@ -37,7 +37,7 @@ sub dynsub{
 }
 
 BEGIN {
-       for my $rs (qw/contest contest_problem job open problem user problem_status contest_status/) {
+       for my $rs (qw/contest contest_problem job open limit problem user problem_status contest_status/) {
                my $rsname = ucfirst $rs;
                $rsname =~ s/_([a-z])/\u$1/gs;
                dynsub PL_N($rs) => sub { $_[0]->resultset($rsname)              };
@@ -56,14 +56,16 @@ sub user_list {
        }
        $contests{$_->rawowner}++ for $self->contest_statuses->all;
 
-       [ sort { $b->{solved} <=> $a->{solved} or $b->{attempted} <=> $a->{attempted} } ## no critic (ProhibitReverseSort)
-               grep { $_->{solved} || $_->{attempted} } map {
+       my @users = sort { $b->{solved} <=> $a->{solved} or $b->{attempted} <=> $a->{attempted} } ## no critic (ProhibitReverseSort)
+               map {
                        my $id = $_->id;
                        +{ $_->get_columns,
                           solved => ($solved{$id} // 0),
                           attempted => ($attempted{$id} // 0),
                           contests => ($contests{$id} // 0) }
-               } $rs->all ]
+               } $rs->all;
+       @users = @users[0 .. 199] if @users > 200;
+       \@users
 }
 
 sub user_entry {
@@ -98,6 +100,10 @@ sub problem_entry {
        push @columns, 'statement';
        push @columns, 'solution' unless $running;
        my $pb = $self->problems->find($id, {columns => \@columns, prefetch => 'owner'});
+       my @limits = map { +{
+               format  => $_->format,
+               timeout => $_->timeout,
+       } } $self->limits->search({problem => $id});
        my $open;
        $open = $self->opens->find_or_create({
                contest => $contest,
@@ -108,6 +114,7 @@ sub problem_entry {
        $contest &&= $self->contest($contest);
        +{
                $pb->get_columns,
+               @limits ? (limits => \@limits) : (),
                owner_name => $pb->owner->name,
                cansubmit => !$contest || !$contest->is_finished,
                $running ? (
This page took 0.025546 seconds and 4 git commands to generate.