Add some utility functions and POD
authorMarius Gavrilescu <marius@ieval.ro>
Thu, 15 May 2014 09:06:16 +0000 (12:06 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Thu, 15 May 2014 09:06:16 +0000 (12:06 +0300)
lib/Gruntmaster/Data.pm
lib/Gruntmaster/Data/Result/Contest.pm
lib/Gruntmaster/Data/Result/ContestProblem.pm
lib/Gruntmaster/Data/Result/Job.pm
lib/Gruntmaster/Data/Result/Open.pm
lib/Gruntmaster/Data/Result/Problem.pm
lib/Gruntmaster/Data/Result/User.pm

index 9fee650af2088752301936c98a8b650eb355bf32..abf9a04c5f91fb32d5df83df790577a9ba690d1b 100644 (file)
@@ -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 E<lt>marius@ieval.roE<gt>
+
+=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
index 829cde652d0900345c88dc0519f4da96bc68e7dd..fcb6a966185f16d9770792c67415c26b6b243b38 100644 (file)
@@ -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<time>).
+
+=head2 is_finished(I<[$time]>)
+
+Returns true if the contest is finished at time I<$time> (which defaults to C<time>).
+
+=head2 is_running(I<[$time]>)
+
+Returns true if the contest is running at time I<$time> (which defaults to C<time>).
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
index a1fe4b43a3de39d8684129760662f6b9562c9457..5d71d88811e72fc50cb66fa504aa04986456c4bb 100644 (file)
@@ -97,3 +97,20 @@ __PACKAGE__->belongs_to(
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
+
+__END__
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
index 1b283a3ed613c9a963ca4e8b4f01050e825940d2..09c85dfdd5d27383959a3a7ed2e8034253f332d1 100644 (file)
@@ -205,6 +205,31 @@ __PACKAGE__->belongs_to(
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-26 15:24:46
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dnYOXMU6Or/Wh0m5A1N5UA
 
+sub rerun {
+       shift->update({daemon => undef, result => -2, result_text => undef});
+}
 
-# You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
+
+__END__
+
+=head1 METHODS
+
+=head2 rerun
+
+Reruns this job.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
index 52b7578b4f469601b90f3958f76ada48b97245f6..9a647333a4e4bb619ec9f3f78b4f64f2203ba53d 100644 (file)
@@ -129,3 +129,20 @@ __PACKAGE__->belongs_to(
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
+
+__END__
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
index 572c48911e5cfe35911690a51ae1e1f26c8ce025..05b6de94f14f935a306cc682ed0ad6afb6ab2ec3 100644 (file)
@@ -284,6 +284,50 @@ __PACKAGE__->many_to_many("contests", "contest_problems", "contest");
 # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-30 12:59:34
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ujwyMJ5Pup1i5NKXkPkg2g
 
+sub is_private {
+       my ($self, $time) = @_;
+       return 1 if $self->private;
+       grep { $_->contest->is_pending($time) } $self->contest_problems;
+}
+
+sub is_in_archive {
+       my ($self, $time) = @_;
+       0 == grep { $_->contest->is_running($time) } $self->contest_problems;
+}
+
+sub rerun {
+       $_->rerun for shift->jobs
+}
 
-# You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
+
+__END__
+
+=head1 METHODS
+
+=head2 is_private(I<[$time]>)
+
+Returns true if the problem is private at time I<$time> (which defaults to C<time>).
+
+=head2 is_in_archive(I<[$time]>)
+
+Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
+
+=head2 rerun
+
+Reruns all jobs for this problem.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
index 1ae671027828ea872bf8174b25bd9e1164e86922..216447edbdeea407e5438363565ff083d5100719 100644 (file)
@@ -180,3 +180,20 @@ __PACKAGE__->has_many(
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
+
+__END__
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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 same terms as Perl itself, either Perl version 5.18.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
This page took 0.017516 seconds and 4 git commands to generate.