From: Marius Gavrilescu Date: Thu, 15 May 2014 09:06:16 +0000 (+0300) Subject: Add some utility functions and POD X-Git-Tag: 5999.000_003~10 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=4a8747effd02a1e0f9dde86b1c81f6c26ce66f04;p=gruntmaster-data.git Add some utility functions and POD --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 9fee650..abf9a04 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -36,3 +36,36 @@ BEGIN { } 1; + +__END__ + +=encoding utf-8 + +=head1 NAME + +Gruntmaster::Data - Gruntmaster 6000 Online Judge -- database interface and tools + +=head1 SYNOPSIS + + my $db = Gruntmaster::Data->connect('dbi:Pg:'); + # Typical DBIC stuff here + +=head1 DESCRIPTION + +No documentation (yet) + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +=cut diff --git a/lib/Gruntmaster/Data/Result/Contest.pm b/lib/Gruntmaster/Data/Result/Contest.pm index 829cde6..fcb6a96 100644 --- a/lib/Gruntmaster/Data/Result/Contest.pm +++ b/lib/Gruntmaster/Data/Result/Contest.pm @@ -152,6 +152,50 @@ __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 +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