From 341fb89345d050a28105184a3fba1be1359e7bd2 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 10 Apr 2015 10:33:33 +0300 Subject: [PATCH] Add rerun_job and db functions --- lib/Gruntmaster/Data.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; -- 2.39.2