]> iEval git - gruntmaster-data.git/commitdiff
Add an open_time key to problem_entry during contests
authorMarius Gavrilescu <marius@ieval.ro>
Tue, 20 Jan 2015 12:44:56 +0000 (14:44 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Tue, 20 Jan 2015 12:44:56 +0000 (14:44 +0200)
lib/Gruntmaster/Data.pm

index fabdbecb9d0b25262dd42542186c3adfb507bd90..f9e0639b2aa69df1d68d552e57dae3f75912008c 100644 (file)
@@ -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 {
This page took 0.029734 seconds and 4 git commands to generate.