From: Marius Gavrilescu Date: Thu, 10 Apr 2014 13:54:44 +0000 (+0300) Subject: Fix opens X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=23bde5b8d2d759b66627b42c0a6726fbae76abef;p=plack-app-gruntmaster.git Fix opens --- diff --git a/lib/Gruntmaster/Page/Generic.pm b/lib/Gruntmaster/Page/Generic.pm index 089337b..e6cd3b2 100644 --- a/lib/Gruntmaster/Page/Generic.pm +++ b/lib/Gruntmaster/Page/Generic.pm @@ -139,6 +139,7 @@ thing { contest => $env->{'gruntmaster.contest'}, problem => $_->{id}, owner => $env->{REMOTE_USER}, + time => time, }) } if $env->{'gruntmaster.contest'} && time >= db($env)->contest($env->{'gruntmaster.contest'})->start; say "Error when creating open: $@"; diff --git a/lib/Gruntmaster/Page/St.pm b/lib/Gruntmaster/Page/St.pm index 4625138..0e3c316 100644 --- a/lib/Gruntmaster/Page/St.pm +++ b/lib/Gruntmaster/Page/St.pm @@ -32,7 +32,7 @@ sub _generate{ if ($ct) { my $open = db($env)->opens->find($ct->id, $job->problem->id, $job->owner->id); - my $time = $job->date - ($open || $ct->start); + my $time = $job->date - ($open ? $open->time : $ct->start); next if $time < 0; my $value = $job->problem->value // LEVEL_VALUES->{$job->problem->level}; $scores{$job->owner->id}{$job->problem->id} = $job->result ? 0 : calc_score ($value, $time, $tries{$job->owner}{$job->problem}, $ct->stop - $ct->start);