X-Git-Url: http://git.ieval.ro/?p=gruntmaster-page.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FSubmit.pm;h=5eed07c379314bd80333a2a554389c41319e8d50;hp=535a5363f8667621bb20a8167efedde0b431fb41;hb=d3200993969efcd4d9c0ce6a5666a012815ad2d5;hpb=99f0c4ecf3eecfff5752cfb1e137fbe4aeb8722d diff --git a/lib/Gruntmaster/Page/Submit.pm b/lib/Gruntmaster/Page/Submit.pm index 535a536..5eed07c 100644 --- a/lib/Gruntmaster/Page/Submit.pm +++ b/lib/Gruntmaster/Page/Submit.pm @@ -22,36 +22,25 @@ sub generate{ $prog = $temp if $temp } die if defined $contest && $contest !~ /^\w+$/ ; - die if defined $contest && (time > contest_end $contest); + die if defined $contest && (time > db($env)->contest($contest)->stop); return reply 'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog; return reply 'Maximum source size is 10KB' if length $prog > 25 * 1024; - return reply 'You must wait 30 seconds between jobs' unless time > user_lastjob ($r->user) + 30; - set_user_lastjob $r->user, time; + return reply 'You must wait 30 seconds between jobs' unless time > db($env)->user($r->user)->lastjob + 30; + db($env)->user($r->user)->lastjob(time)->update; - local $Gruntmaster::Data::contest = $contest if $contest; - - my $job = push_job ( + db($env)->jobs->create({ + defined $contest ? (contest => $contest) : (), date => time, - problem => $problem, - user => $r->user, - defined $private ? (private => $private) : (), - defined $contest ? (contest => $contest, private => 1) : (), - filesize => length $prog, extension => FORMAT_EXTENSION->{$format}, - ); - - set_job_inmeta $job, { - files => { - prog => { - format => $format, - name => 'prog.' . FORMAT_EXTENSION->{$format}, - content => $prog, - } - } - }; + format => $format, + defined $private ? (private => $private) : (), + probem => $problem, + source => $prog, + user => $r->user + }); $contest //= ''; - PUBLISH 'jobs', "$contest.$job"; + #PUBLISH 'jobs', "$contest.$job"; [303, [Location => $r->path =~ s,/pb/\w+/submit$,/log/,r], ['']] }