]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data.pm
Exclude pending jobs from standings
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index 40751bed17ca6c02cd05b04e8beb3c3f16880630..bcb3571dbaab1e2845671e9d82dcbe94f1bc3a0a 100644 (file)
@@ -138,7 +138,8 @@ sub contest_entry {
 sub job_list {
        my ($self, %args) = @_;
        $args{page} //= 1;
-       my $rs = $self->jobs->search({contest => $args{contest}}, {order_by => {-desc => 'me.id'}, prefetch => ['problem', 'owner'], rows => JOBS_PER_PAGE, page => $args{page}});
+       my $rs = $self->jobs->search(undef, {order_by => {-desc => 'me.id'}, prefetch => ['problem', 'owner', 'contest'], rows => JOBS_PER_PAGE, page => $args{page}});
+       $rs = $rs->search({contest => $args{contest} || undef}) if exists $args{contest};
        $rs = $rs->search({'me.private'=> 0})          unless $args{private};
        $rs = $rs->search({'me.owner'  => $args{owner}})   if $args{owner};
        $rs = $rs->search({problem     => $args{problem}}) if $args{problem};
@@ -147,6 +148,7 @@ sub job_list {
                        my %params = $_->get_columns;
                        $params{owner_name}   = $_->owner->name;
                        $params{problem_name} = $_->problem->name;
+                       $params{contest_name} = $_->contest->name if $params{contest};
                        $params{results} &&= decode_json $params{results};
                        $params{size}      = length $params{source};
                        delete $params{source};
@@ -181,8 +183,8 @@ sub update_status {
        for (@jobs) {
                my $pb = $_->get_column('problem');
                $private{$pb} //= $_->problem->is_private;
-               next if !$private{$pb};
-               $hash{$pb, $_->get_column('owner')} = [$_->id, $_->result ? 0 : 1] for @jobs;
+               next if $private{$pb};
+               $hash{$pb, $_->get_column('owner')} = [$_->id, $_->result ? 0 : 1];
        }
 
        my @problem_statuses = map { [split ($;), @{$hash{$_}} ] } keys %hash;
This page took 0.028791 seconds and 4 git commands to generate.