]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data.pm
Exclude pending jobs from standings
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index 741061bfc99409a1c6b47d67aac59ec6be9140ed..bcb3571dbaab1e2845671e9d82dcbe94f1bc3a0a 100644 (file)
@@ -132,13 +132,14 @@ sub contest_list {
 sub contest_entry {
        my ($self, $id) = @_;
        my $ct = $self->contest($id);
-       +{ $ct->get_columns, started => !$ct->is_pending, owner_name => $ct->owner->name }
+       +{ $ct->get_columns, started => !$ct->is_pending, finished => $ct->is_finished, owner_name => $ct->owner->name }
 }
 
 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};
@@ -174,12 +176,15 @@ sub job_entry {
 
 sub update_status {
        my ($self) = @_;
-       my @jobs = $self->jobs->search({private => 0}, {cache => 1, prefetch => 'problem'})->all;
+       my @jobs = $self->jobs->search({'me.private' => 0}, {cache => 1, prefetch => 'problem'})->all;
 
+       my %private;
        my %hash;
        for (@jobs) {
-               next if !$_->problem->is_in_archive;
-               $hash{$_->get_column('problem'), $_->get_column('owner')} = [$_->id, $_->result ? 0 : 1] 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];
        }
 
        my @problem_statuses = map { [split ($;), @{$hash{$_}} ] } keys %hash;
This page took 0.022161 seconds and 4 git commands to generate.