From 9396be04bc50afcc4bb29cfb21d32dffbe65111d Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 20 Jan 2015 14:44:56 +0200 Subject: [PATCH] Add an open_time key to problem_entry during contests --- lib/Gruntmaster/Data.pm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) 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 { -- 2.30.2