From 86a97f649d2f98d8a42254f9b33b9f7b5979105f Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 12 Dec 2014 14:41:41 +0200 Subject: [PATCH] Remove support for archive standings --- lib/Gruntmaster/Data.pm | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 5318cbc..023966f 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -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; -- 2.39.2