]> iEval git - gruntmaster-data.git/commitdiff
Remove support for archive standings
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 12 Dec 2014 12:41:41 +0000 (14:41 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 12 Dec 2014 12:41:41 +0000 (14:41 +0200)
lib/Gruntmaster/Data.pm

index 5318cbcfcab23f5bc7a3a1fe865492a5e245db97..023966f71e263315316fe5d1dd76a6d06d47032a 100644 (file)
@@ -55,24 +55,19 @@ sub calc_score{
 
 sub standings {
        my ($self, $ct) = @_;
-       $ct &&= $self->contest($ct);
+       my $ctobj = $self->contest($ct);
 
-       my @problems = map { $_->rawproblem } $self->contest_problems->search({contest => $ct && $ct->id}, {qw/join problem order_by problem.level/});
+       my @problems = map { $_->rawproblem } $self->contest_problems->search({contest => $ct}, {qw/join problem order_by problem.level/});
        my (%scores, %tries, %opens);
-       $opens{$_->rawproblem, $_->rawowner} = $_ for $self->opens->search({contest => $ct && $ct->id});
-       for my $job ($self->jobs->search({contest => $ct && $ct->id}, {qw/order_by me.id prefetch/ => [qw/problem/]})) {
-               if ($ct) {
-                       my $open = $opens{$job->rawproblem, $job->rawowner};
-                       my $time = $job->date - ($open ? $open->time : $ct->start);
-                       next if $time < 0;
-                       my $value = $job->problem->value;
-                       my $factor = $job->result ? 0 : 1;
-                       $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/s;
-                       $scores{$job->rawowner}{$job->rawproblem} = int ($factor * calc_score ($value, $time, $tries{$job->rawowner}{$job->rawproblem}++, $ct->stop - $ct->start));
-               } else {
-                       no warnings 'numeric'; ## no critic (ProhibitNoWarnings)
-                       $scores{$job->rawowner}{$job->rawproblem} = 0 + $job->result_text || ($job->result ? 0 : 100)
-               }
+       $opens{$_->rawproblem, $_->rawowner} = $_ for $self->opens->search({contest => $ct});
+       for my $job ($self->jobs->search({contest => $ct}, {qw/order_by me.id prefetch/ => [qw/problem/]})) {
+               my $open = $opens{$job->rawproblem, $job->rawowner};
+               my $time = $job->date - ($open ? $open->time : $ctobj->start);
+               next if $time < 0;
+               my $value = $job->problem->value;
+               my $factor = $job->result ? 0 : 1;
+               $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/s;
+               $scores{$job->rawowner}{$job->rawproblem} = int ($factor * calc_score ($value, $time, $tries{$job->rawowner}{$job->rawproblem}++, $ctobj->stop - $ctobj->start));
        }
 
        my %user_to_name = map { $_ => $_->name } $self->users->all;
@@ -84,7 +79,6 @@ sub standings {
                        user_name => $user_to_name{$user},
                        score => sum (values %{$scores{$user}}),
                        scores => [map { $scores{$user}{$_} // '-'} @problems],
-                       problems => $ct,
                }
        } keys %scores;
 
This page took 0.029528 seconds and 4 git commands to generate.