use parent qw/Exporter/;
our $VERSION = '5999.000_013';
-our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry problem_full contest_list contest_entry contest_full contest_has_problem job_list job_entry job_full create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation)
+our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry contest_list contest_entry contest_has_problem job_list job_entry create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation)
use JSON::MaybeXS qw/decode_json/;
use HTTP::Tiny;
contest_list_sth => 'SELECT * FROM contest_entry',
contest_entry_sth => 'SELECT * FROM contest_entry WHERE id = ?',
- contest_full_sth => 'SELECT * FROM contests WHERE id = ?',
contest_problems_sth => 'SELECT problem FROM contest_problems JOIN problems pb ON problem=pb.id WHERE contest = ? ORDER BY pb.value',
contest_has_problem_sth => 'SELECT EXISTS(SELECT 1 FROM contest_problems WHERE contest = ? AND problem = ?)',
opens_sth => 'SELECT problem,owner,time FROM opens WHERE contest = ?',
problem_entry_sth => 'SELECT ' . (join ',', @{PROBLEM_PUBLIC_COLUMNS()}, 'statement', 'solution') . ' FROM problems WHERE id = ?',
- problem_full_sth => 'SELECT * FROM problems WHERE id = ?',
limits_sth => 'SELECT format,timeout FROM limits WHERE problem = ?',
problem_values_sth => 'SELECT id,value FROM problems',
job_entry_sth => 'SELECT * FROM job_entry WHERE id = ?',
- job_full_sth => 'SELECT * FROM jobs WHERE id = ?',
rerun_job_sth => 'UPDATE jobs SET daemon=NULL,result=-2,result_text=NULL,results=NULL,errors=NULL WHERE id = ?',
take_job_sth => 'UPDATE jobs SET daemon=? WHERE id = (SELECT id FROM jobs WHERE daemon IS NULL LIMIT 1 FOR UPDATE) RETURNING id',
$ret
}
-sub problem_full { scalar query(problem_full_sth => $_[0])->hash }
-
sub contest_list { add_names query('contest_list_sth')->hashes }
sub contest_entry { add_names query(contest_entry_sth => $_[0])->hash }
-sub contest_full { scalar query(contest_full_sth => $_[0])->hash }
-
sub contest_has_problem { query('contest_has_problem_sth', @_[0, 1])->flat }
sub job_list {
$ret
}
-sub job_full { scalar query(job_full_sth => $_[0])->hash }
-
sub create_job {
my (%args) = @_;
$db->update('users', {lastjob => time}, {id => $args{owner}});
sub take_job {
my ($daemon) = @_;
my $id = query(take_job_sth => $daemon)->list;
- return $id ? job_full $id : undef;
+ return $id ? db->select(jobs => '*', {id => $id})->hash : undef;
}
sub finish_job {