X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FContest.pm;h=166d5448d429b306eefc29c23aa8800179eb87ba;hb=9bb399215eed61555c05f025aedf6dc53f4e977d;hp=829cde652d0900345c88dc0519f4da96bc68e7dd;hpb=4ed3f8e7c64594bb4ea26abb1c4fb51a5a8258d6;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/Contest.pm b/lib/Gruntmaster/Data/Result/Contest.pm index 829cde6..166d544 100644 --- a/lib/Gruntmaster/Data/Result/Contest.pm +++ b/lib/Gruntmaster/Data/Result/Contest.pm @@ -135,7 +135,7 @@ __PACKAGE__->belongs_to( "owner", "Gruntmaster::Data::Result::User", { id => "owner" }, - { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, + { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, ); =head2 problems @@ -149,9 +149,53 @@ Composing rels: L -> problem __PACKAGE__->many_to_many("problems", "contest_problems", "problem"); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-06 12:41:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T5tUpU1TOahLKzx9iVie3A +# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:03:32 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8PPzBpDmSTq4ukKuxIlLlQ +sub is_pending { + my ($self, $time) = @_; + $self->start > ($time // time) +} + +sub is_finished { + my ($self, $time) = @_; + $self->stop <= ($time // time) +} + +sub is_running { + my ($self, $time) = @_; + !$self->is_pending($time) && !$self->is_finished($time) +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; + +__END__ + +=head1 METHODS + +=head2 is_pending(I<[$time]>) + +Returns true if the contest is pending at time I<$time> (which defaults to C