NAME

Gruntmaster::Data - Gruntmaster 6000 Online Judge -- database interface and tools

SYNOPSIS

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

DESCRIPTION

Gruntmaster::Data is the interface to the Gruntmaster 6000 database. Read the DBIx::Class documentation for usage information.

In addition to the typical DBIx::Class::Schema methods, this module contains several convenience methods:

contests

Equivalent to $schema->resultset('Contest')

contest_problems

Equivalent to $schema->resultset('ContestProblem')

jobs

Equivalent to $schema->resultset('Job')

problems

Equivalent to $schema->resultset('Problem')

users

Equivalent to $schema->resultset('User')

contest($id)

Equivalent to $schema->resultset('Contest')->find($id)

job($id)

Equivalent to $schema->resultset('Job')->find($id)

problem($id)

Equivalent to $schema->resultset('Problem')->find($id)

user($id)

Equivalent to $schema->resultset('User')->find($id)

user_list

Returns a list of users as an arrayref containing hashrefs.

user_entry($id)

Returns a hashref with information about the user $id.

problem_list([%args])

Returns a list of problems grouped by level. A hashref with levels as keys.

Takes the following arguments:

owner

Only show problems owned by this user

contest

Only show problems in this contest

problem_entry($id, [$contest, $user])

Returns a hashref with information about the problem $id. If $contest and $user are present, problem open data is updated.

contest_list([%args])

Returns a list of contests grouped by state. A hashref with the following keys:

pending

An arrayref of hashrefs representing pending contests

running

An arrayref of hashrefs representing running contests

finished

An arrayref of hashrefs representing finished contests

Takes the following arguments:

owner

Only show contests owned by this user.

contest_entry($id)

Returns a hashref with information about the contest $id.

job_list([%args])

Returns a list of jobs as an arrayref containing hashrefs. Takes the following arguments:

owner

Only show jobs submitted by this user.

contest

Only show jobs submitted in this contest.

problem

Only show jobs submitted for this problem.

page

Show this page of results. Defaults to 1. Pages have 10 entries, and the first page has the most recent jobs.

job_entry($id)

Returns a hashref with information about the job $id.

AUTHOR

Marius Gavrilescu <marius@ieval.ro>

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.