X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData.pm;h=7b90c872df7d2717aee7261f99e3e84b417e79c2;hb=ed105ac3a99703b6d428f16601ec6642a35c7ab8;hp=98e62d69b77177fe32e77abf75a264166c162d3a;hpb=dcf7f640534d6ad6d0273ac5b8bb1e9892fcaa56;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 98e62d6..7b90c87 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -3,8 +3,8 @@ use 5.014; use warnings; use parent qw/Exporter/; -our $VERSION = '5999.000_013'; -our @EXPORT = qw/dbinit 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 open_problem/; +our $VERSION = '5999.000_016'; +our @EXPORT = qw/dbinit 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 rerun_problem take_job finish_job open_problem/; our @EXPORT_OK = @EXPORT; use JSON::MaybeXS qw/decode_json/; @@ -36,6 +36,7 @@ my %statements = ( job_entry_sth => 'SELECT * FROM job_entry WHERE id = ?', + rerun_problem_sth => 'UPDATE jobs SET daemon=NULL,result=-2,result_text=NULL,results=NULL,errors=NULL WHERE problem = ?', 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', ); @@ -46,6 +47,7 @@ sub db () { $db } sub dbinit { $db = DBIx::Simple->new(@_); $db->keep_statements = 100; + $db->dbh->do('SET search_path TO gruntmaster, public'); }; sub purge; @@ -191,7 +193,10 @@ sub standings { $opens{$problem, $owner} = $time; } - my $jobs = $db->select('job_entry', '*', {contest => $ct->{id}}, 'id'); + # result IS NULL if job was never run + # result = -2 if job is being rerun + my %where = (contest => $ct->{id}, result => {'>=', 0}); + my $jobs = $db->select('job_entry', '*', \%where, 'id'); while (my $job = $jobs->hash) { my $open = $opens{$job->{problem}, $job->{owner}} // $ct->{start}; @@ -242,6 +247,12 @@ sub update_status { $db->commit } +sub rerun_problem { + my ($problem) = @_; + _query rerun_problem_sth => $problem; + purge '/log/'; +} + sub rerun_job { my ($id) = @_; _query rerun_job_sth => $id; @@ -263,6 +274,7 @@ sub finish_job { db->update(jobs => \%args, {id => $job->{id}}); purge '/log/'; purge '/log/' . $job->{id}; + purge '/st/' . $job->{contest} if $job->{contest}; return if $private; my $status = { problem => $job->{problem}, @@ -467,10 +479,10 @@ Marius Gavrilescu Emarius@ieval.roE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2014 by Marius Gavrilescu +Copyright (C) 2014-2016 by Marius Gavrilescu This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself, either Perl version 5.18.1 or, +it under the same terms as Perl itself, either Perl version 5.20.1 or, at your option, any later version of Perl 5 you may have available.