NAME

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

SYNOPSIS

DESCRIPTION

Gruntmaster::Data is the interface to the Gruntmaster 6000 database.

All functions are exported by default.

dbinit(@args)

This function connects to the database. @args are the arguments passed to the DBIx::Simple constructor.

purge($url_path)

Purges a relative URL from the Varnish Cache by sending PURGE $url_path requests to all hosts in the PURGE_HOSTS environment variable.

db

Returns a DBIx::Simple object for interacting with the database directly. Use this when no other function in this module is suitable.

user_list

Returns an arrayref of the top 200 users.

user_entry($id)

Returns a hashref describing the user $id.

problem_list([%args])

Returns an arrayref of problems.

Takes the following named arguments:

owner

Only show problems owned by this user

contest

Only show problems in this contest

private

If true, include private problems. Always true if contest is present.

solution

If true, include problem solutions

problem_entry(i<$id>, [$contest])

Returns a hashref describing the problem $id. If $contest is present, contest start and stop times are included, and the solution is deleted.

contest_list

Returns an arrayref of contests.

contest_entry($id)

Returns a hashref describing the contest $id.

contest_has_problem($contest, $problem)

Returns true if the contest $contest includes the problem $problem, false otherwise.

job_list([%args])

In scalar context, returns an arrayref of jobs. In list context, returns an arrayref of jobs and a hashref of information about pages.

Takes the following named arguments:

page

Show this page of the job log. Defaults to 1.

owner

Only show jobs submitted by this user.

contest

Only show jobs submitted in this contest.

problem

Only show jobs submitted for this problem.

result

Only show jobs with this result (see the constants in Gruntmaster::Daemon::Constants).

private

If true, include private jobs. Defaults to false.

job_entry($id)

Returns a hashref describing the job $id.

create_job(%args)

Insert a new job into the database. This function also updates the lastjob field for the job's owner.

standings($ct)

Returns an arrayref of the standings of contest $ct.

update_status

Rebuilds the problem_status and contest_status tables.

rerun_job($id)

Marks the job $id as pending and clears its results, so that it will be run again by the daemon.

take_job($daemon)

Marks a random job as being run by $daemon. Returns a hashref describing the job, or undef if no job was available.

finish_job($job, $private, %results)

Updates the job $job with the results in %results. If $private is false, also updates the problem_status table.

open_problem($contest, $problem, $owner, $time)

Notes that $owner has opened the problem $problem of contest $contest at time $time. If the opens table already contains this ($contest, $problem, $owner) triplet, this function does nothing.

AUTHOR

Marius Gavrilescu <marius@ieval.ro>

COPYRIGHT AND LICENSE

Copyright (C) 2014-2015 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.20.1 or, at your option, any later version of Perl 5 you may have available.