X-Git-Url: http://git.ieval.ro/?p=gruntmaster-data.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FData.pm;h=530aba7f80e2fb5142fde000d1a8dd2eaf4aaea3;hp=2468d034562d9226ab10c3a9f5a83bc93d694c7e;hb=e1b6fd19f5724ce68ee92aaeae1c0ddf7a6a2561;hpb=3ceb2ad025c6289bf36dc936a6ad2fa3d3d19aec diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 2468d03..530aba7 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/; ## no critic (ProhibitAutomaticExportation) +our $VERSION = '5999.000_014'; +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 @EXPORT_OK = @EXPORT; use JSON::MaybeXS qw/decode_json/; @@ -276,6 +276,17 @@ sub finish_job { purge '/us/' . $job->{owner}; } +sub open_problem { + my ($contest, $problem, $owner, $time) = @_; + my $ct = contest_entry($contest); + return unless $ct->{id} && $time >= $ct->{start} && $time < $ct->{stop}; ## no critic (ProhibitNegativeExpressionsInUnlessAndUntilConditions) + eval { db->insert(opens => { ## no critic (RequireCheckingReturnValueOfEval) + contest => $contest, + problem => $problem, + owner => $owner, + time => $time}) }; +} + my @PURGE_HOSTS = exists $ENV{PURGE_HOSTS} ? split ' ', $ENV{PURGE_HOSTS} : (); my $ht = HTTP::Tiny->new; @@ -441,6 +452,13 @@ describing the job, or undef if no job was available. Updates the job $job with the results in %results. If $private is false, also updates the problem_status table. +=item B(I<$contest>, I<$problem>, I<$owner>, I<$time>) + +Notes that I<$owner> has opened the problem I<$problem> of contest +I<$contest> at time I<$time>. If the C table already contains +this (I<$contest>, I<$problem>, I<$owner>) triplet, this function does +nothing. + =back =head1 AUTHOR @@ -449,10 +467,10 @@ Marius Gavrilescu Emarius@ieval.roE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2014 by Marius Gavrilescu +Copyright (C) 2014-2015 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.