X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData.pm;h=4393a62de6f687d724f8cab874b7e190cfd31283;hb=5bfe4fee59691741265842a2d06cf53a1d86aa6e;hp=ab0fe36de464f11906686b1134a8bd872db5b8e7;hpb=4623c9f2c2bd5309fcd57e9da2f2e18fe3dcdb45;p=gruntmaster-data.git 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;