-sub standings {
- my ($self, $ct) = @_;
- $ct &&= $self->contest($ct);
-
- my @problems = map { $_->problem } $self->contest_problems->search({contest => $ct && $ct->id}, {qw/join problem order_by problem.level/});
- my (%scores, %tries);
- for my $job ($self->jobs->search({contest => $ct && $ct->id}, {order_by => 'id'})) {
- if ($ct) {
- 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;
- my $factor = $job->result ? 0 : 1;
- $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/s;
- $scores{$job->owner->id}{$job->problem->id} = int ($factor * calc_score ($value, $time, $tries{$job->owner->id}{$job->problem->id}++, $ct->stop - $ct->start));
- } else {
- no warnings 'numeric'; ## no critic (ProhibitNoWarnings)
- $scores{$job->owner->id}{$job->problem->id} = 0 + $job->result_text || ($job->result ? 0 : 100)
- }
+ for my $row ($self->problem_statuses->all) {
+ $solved {$row->rawowner}++ if $row->solved;
+ $attempted{$row->rawowner}++ unless $row->solved;