From: Marius Gavrilescu Date: Fri, 10 Apr 2015 07:33:33 +0000 (+0300) Subject: Add rerun_job and db functions X-Git-Tag: 5999.000_014~32 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=341fb89345d050a28105184a3fba1be1359e7bd2;p=gruntmaster-data.git Add rerun_job and db functions --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index ab0fe36..4393a62 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -4,7 +4,7 @@ use warnings; use parent qw/Exporter/; our $VERSION = '5999.000_013'; -our @EXPORT = qw/purge user_list user_entry problem_list problem_entry contest_list contest_entry contest_full contest_has_problem job_list job_entry job_full create_job standings update_status/; ## no critic (ProhibitAutomaticExportation) +our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry contest_list contest_entry contest_full contest_has_problem job_list job_entry job_full create_job standings update_status rerun_job/; ## no critic (ProhibitAutomaticExportation) use JSON::MaybeXS qw/decode_json/; use HTTP::Tiny; @@ -38,9 +38,12 @@ my %statements = ( 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 = ?', ); our $db; +sub db () { $db } sub init { $db = DBIx::Simple->new(@_); @@ -281,6 +284,13 @@ sub update_status { $db->commit } +sub rerun_job { + my ($id) = @_; + $db->query(rerun_job_sth => $id); + purge '/log/'; + purge "/log/$id"; +} + my @PURGE_HOSTS = exists $ENV{PURGE_HOSTS} ? split ' ', $ENV{PURGE_HOSTS} : (); my $ht = HTTP::Tiny->new;