Bump version and add changelog entry
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index 48de966aed29da3093ccc14d92e73ac97ea0b1e6..457f12b93b32d2c68ec9b880ba889c160b085946 100644 (file)
+use utf8;
 package Gruntmaster::Data;
 
-use 5.014002;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
 use strict;
 use warnings;
 
-require Exporter;
-
-our @ISA = qw(Exporter);
+use base 'DBIx::Class::Schema';
 
-# Items to export into callers namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
+__PACKAGE__->load_namespaces;
 
-# This allows declaration      use Gruntmaster::Data ':all';
-# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
-# will save memory.
-our %EXPORT_TAGS = ( 'all' => [ qw(
-       
-) ] );
 
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-05 13:11:39
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dAEmtAexvUaNXLgYz2rNEg
 
-our @EXPORT = qw(
-       
-);
+our $VERSION = '5999.000_004';
 
-our $VERSION = '5999.000_001';
-$VERSION = eval $VERSION;  # see L<perlmodstyle>
+use Lingua::EN::Inflect qw/PL_N/;
+use Sub::Name qw/subname/;
 
+sub dynsub{
+       our ($name, $sub) = @_;
+       no strict 'refs';
+       *$name = subname $name => $sub
+}
 
-# Preloaded methods go here.
+BEGIN {
+       for my $rs (qw/contest contest_problem job open problem user/) {
+               my $rsname = ucfirst $rs;
+               $rsname =~ s/_([a-z])/\u$1/g;
+               dynsub PL_N($rs) => sub { $_[0]->resultset($rsname)              };
+               dynsub      $rs  => sub { $_[0]->resultset($rsname)->find($_[1]) };
+       }
+}
 
 1;
+
 __END__
-# Below is stub documentation for your module. You'd better edit it!
+
+=encoding utf-8
 
 =head1 NAME
 
-Gruntmaster::Data - Perl extension for blah blah blah
+Gruntmaster::Data - Gruntmaster 6000 Online Judge -- database interface and tools
 
 =head1 SYNOPSIS
 
-  use Gruntmaster::Data;
-  blah blah blah
+  my $db = Gruntmaster::Data->connect('dbi:Pg:');
+
+  my $problem = $db->problem('my_problem');
+  $problem->update({timeout => 2.5}); # Set time limit to 2.5 seconds
+  $problem->rerun; # And rerun all jobs for this problem
+
+  # ...
+
+  my $contest = $db->contests->create({ # Create a new contest
+    id => 'my_contest',
+    name => 'My Awesome Contest',
+    start => time + 100,
+    end => time + 1900,
+  });
+  $db->contest_problems->create({ # Add a problem to the contest
+    contest => 'my_contest',
+    problem => 'my_problem',
+  });
+
+  say 'The contest has not started yet' if $contest->is_pending;
+
+  # ...
+
+  my @jobs = $db->jobs->search({contest => 'my_contest', owner => 'MGV'})->all;
+  $_->rerun for @jobs; # Rerun all jobs sent by MGV in my_contest
 
 =head1 DESCRIPTION
 
-Stub documentation for Gruntmaster::Data, created by h2xs. It looks like the
-author of the extension was negligent enough to leave the stub
-unedited.
+Gruntmaster::Data is the interface to the Gruntmaster 6000 database. Read the L<DBIx::Class> documentation for usage information.
+
+In addition to the typical DBIx::Class::Schema methods, this module contains several convenience methods:
+
+=over
+
+=item contests
+
+Equivalent to C<< $schema->resultset('Contest') >>
+
+=item contest_problems
+
+Equivalent to C<< $schema->resultset('ContestProblem') >>
+
+=item jobs
+
+Equivalent to C<< $schema->resultset('Job') >>
+
+=item problems
+
+Equivalent to C<< $schema->resultset('Problem') >>
+
+=item users
+
+Equivalent to C<< $schema->resultset('User') >>
 
-Blah blah blah.
+=item contest($id)
 
-=head2 EXPORT
+Equivalent to C<< $schema->resultset('Contest')->find($id) >>
 
-None by default.
+=item job($id)
 
+Equivalent to C<< $schema->resultset('Job')->find($id) >>
 
+=item problem($id)
 
-=head1 SEE ALSO
+Equivalent to C<< $schema->resultset('Problem')->find($id) >>
 
-Mention other useful documentation such as the documentation of
-related modules or operating system documentation (such as man pages
-in UNIX), or any relevant external documentation such as RFCs or
-standards.
+=item user($id)
 
-If you have a mailing list set up for your module, mention it here.
+Equivalent to C<< $schema->resultset('User')->find($id) >>
 
-If you have a web site set up for your module, mention it here.
+=back
 
 =head1 AUTHOR
 
-Marius Gavrilescu, E<lt>marius@E<gt>
+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.2 or,
+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.
 
 
This page took 0.012348 seconds and 4 git commands to generate.