From: Marius Gavrilescu Date: Tue, 20 Jan 2015 12:44:56 +0000 (+0200) Subject: Add an open_time key to problem_entry during contests X-Git-Tag: 5999.000_014~98 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=9396be04bc50afcc4bb29cfb21d32dffbe65111d;p=gruntmaster-data.git Add an open_time key to problem_entry during contests --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index fabdbec..f9e0639 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -93,16 +93,24 @@ sub problem_entry { my $columns = PROBLEM_PUBLIC_COLUMNS; push @$columns, 'solution' unless $running; my $pb = $self->problems->find($id, {columns => $columns, prefetch => 'owner'}); - eval { ## no critic (RequireCheckingReturnValueOfEval) - $self->opens->create({ - contest => $contest, - problem => $id, - owner => $user, - time => time, - }) - } if $running; + my $open; + $open = $self->opens->find_or_create({ + contest => $contest, + problem => $id, + owner => $user, + time => time, + }) if $running; $contest &&= $self->contest($contest); - +{ $pb->get_columns, owner_name => $pb->owner->name, cansubmit => $contest ? $running : 1, $running ? (contest_start => $contest->start, contest_stop => $contest->stop) : () } + +{ + $pb->get_columns, + owner_name => $pb->owner->name, + cansubmit => $running || !$contest, + $running ? ( + contest_start => $contest->start, + contest_stop => $contest->stop, + open_time => $open->time + ) : (), + } } sub contest_list {