X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FContest.pm;h=4ea2f1ae988f189b76d074073c06105b9940ba47;hb=e6a01c9f7e096edf7fb3e53d6e32fcb043b7f29d;hp=77ac716b8c6de2d9e45c7f380e6e8014611c023a;hpb=1de10923aedb415f33631532c45b3589b1fc9f48;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/Contest.pm b/lib/Gruntmaster/Data/Result/Contest.pm index 77ac716..4ea2f1a 100644 --- a/lib/Gruntmaster/Data/Result/Contest.pm +++ b/lib/Gruntmaster/Data/Result/Contest.pm @@ -6,7 +6,7 @@ package Gruntmaster::Data::Result::Contest; =head1 NAME -Gruntmaster::Data::Result::Contest +Gruntmaster::Data::Result::Contest - List of contests =cut @@ -38,11 +38,15 @@ __PACKAGE__->table("contests"); data_type: 'integer' is_nullable: 0 +Unix time when contest starts + =head2 stop data_type: 'integer' is_nullable: 0 +Unix time when contest ends + =head2 owner data_type: 'text' @@ -164,11 +168,18 @@ Composing rels: L -> problem __PACKAGE__->many_to_many("problems", "contest_problems", "problem"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-11 23:51:27 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nu+Io9AhYkzYCky5UpCaKQ +# 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) @@ -224,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 }