]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data.pm
Add contest_start and contest_stop to pb_entry
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index c3aa9975f62ede2c83ae5e9d63856789e8dd5f07..b27444335bbc301b7cdd004031e146db0ecad686 100644 (file)
@@ -15,10 +15,10 @@ __PACKAGE__->load_namespaces;
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-05 13:11:39
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dAEmtAexvUaNXLgYz2rNEg
 
-our $VERSION = '5999.000_008';
+our $VERSION = '5999.000_010';
 
 use Lingua::EN::Inflect qw/PL_N/;
-use JSON qw/decode_json/;
+use JSON::MaybeXS qw/decode_json/;
 use List::Util qw/sum/;
 use PerlX::Maybe qw/maybe/;
 use Sub::Name qw/subname/;
@@ -42,13 +42,6 @@ BEGIN {
        }
 }
 
-use constant LEVEL_VALUES => {
-       beginner => 100,
-       easy => 250,
-       medium => 500,
-       hard => 1000,
-};
-
 sub calc_score{
        my ($mxscore, $time, $tries, $totaltime) = @_;
        my $score = $mxscore;
@@ -71,7 +64,7 @@ sub standings {
                        my $open = $self->opens->find($ct->id, $job->problem->id, $job->owner->id);
                        my $time = $job->date - ($open ? $open->time : $ct->start);
                        next if $time < 0;
-                       my $value = $job->problem->value // LEVEL_VALUES->{$job->problem->level};
+                       my $value = $job->problem->value;
                        my $factor = $job->result ? 0 : 1;
                        $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/;
                        $scores{$job->owner->id}{$job->problem->id} = int ($factor * calc_score ($value, $time, $tries{$job->owner->id}{$job->problem->id}++, $ct->stop - $ct->start));
@@ -133,7 +126,8 @@ sub problem_entry {
                        time => time,
                })
        } if $running;
-       +{ $pb->get_columns, owner_name => $pb->owner->name, cansubmit => $contest ? $running : 1 }
+       $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) : () }
 }
 
 sub contest_list {
This page took 0.023271 seconds and 4 git commands to generate.