]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data/Result/Contest.pm
Exclude pending jobs from standings
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / Contest.pm
index e7b72259d7b10fc05c3736a7200347f4fd3405ea..02a50caeb819c86c5891ed7c0ee4b4e72dfeb0fa 100644 (file)
@@ -171,8 +171,15 @@ __PACKAGE__->many_to_many("problems", "contest_problems", "problem");
 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:54:00
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IxxZqQwKisBwDabCNUD55Q
 
+use Class::Method::Modifiers qw/after/;
 use List::Util qw/sum/;
 
+after qw/insert update delete/ => sub {
+       my ($self) = @_;
+       Gruntmaster::Data::purge '/ct/';
+       Gruntmaster::Data::purge '/ct/' . $self->id;
+};
+
 sub is_pending {
        my ($self, $time) = @_;
        $self->start > ($time // time)
@@ -206,7 +213,7 @@ sub standings {
        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});
-       for my $job ($self->jobs->search({contest => $ct}, {qw/order_by me.id prefetch/ => [qw/problem/]})) {
+       for my $job ($self->jobs->search({contest => $ct, result => {'!=', undef}}, {qw/order_by me.id prefetch/ => [qw/problem/]})) {
                my $open = $opens{$job->rawproblem, $job->rawowner};
                my $time = $job->date - ($open ? $open->time : $self->start);
                next if $time < 0;
@@ -228,7 +235,7 @@ sub standings {
                }
        } keys %scores;
 
-       $st[0]->{rank} = 1;
+       $st[0]->{rank} = 1 if @st;
        $st[$_]->{rank} = $st[$_ - 1]->{rank} + ($st[$_]->{score} < $st[$_ - 1]->{score}) for 1 .. $#st;
        @st
 }
This page took 0.025255 seconds and 4 git commands to generate.