X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData.pm;h=bcb3571dbaab1e2845671e9d82dcbe94f1bc3a0a;hb=c84272d15528bf612dad24af20f657b0063f3402;hp=16a6176fcf65e6b0cf8c5c5d41590d5e6bdb6c7e;hpb=4db1f7258198bcbb2398e05488f8a0e7a6887337;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 16a6176..bcb3571 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -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,10 +176,17 @@ sub job_entry { sub update_status { my ($self) = @_; - my @jobs = $self->jobs->search(undef, {cache => 1})->all; + my @jobs = $self->jobs->search({'me.private' => 0}, {cache => 1, prefetch => 'problem'})->all; + my %private; my %hash; - $hash{$_->get_column('problem'), $_->get_column('owner')} = [$_->id, $_->result ? 0 : 1] for @jobs; + 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; my @contest_statuses = map {