Add rerun_job and db functions
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 10 Apr 2015 07:33:33 +0000 (10:33 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 10 Apr 2015 07:33:33 +0000 (10:33 +0300)
lib/Gruntmaster/Data.pm

index ab0fe36de464f11906686b1134a8bd872db5b8e7..4393a62de6f687d724f8cab874b7e190cfd31283 100644 (file)
@@ -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;
 
This page took 0.011757 seconds and 4 git commands to generate.