}
BEGIN {
- for my $cmd (qw/multi exec smembers get hget hset sadd incr hmset/) {
- dynsub uc $cmd, sub { say $cmd;exit;$redis->$cmd(@_) };
+ for my $cmd (qw/multi exec smembers get hget hset sadd srem incr hmset hsetnx/) {
+ dynsub uc $cmd, sub { say "Arguments to \U$cmd: ", join ', ', @_; $redis->$cmd(@_) };
}
}
sub problems () { SMEMBERS cp . 'problem' }
sub contests () { SMEMBERS cp . 'contest' }
-sub jobcard () { GET cp . 'job' }
+sub jobcard () { GET cp . 'job' }
-sub job_results (_) { decode_json HGET cp . "job.$_[0]", 'results' }
-sub set_job_results ($+) { HSET cp . "job.$_[0]", 'results', encode_json $_[1] }
-sub problem_meta (_) { decode_json HGET cp . "pb.$_[0]", 'meta' }
-sub set_problem_meta ($+) { HSET cp . "pb.$_[0]", 'meta', encode_json $_[1] }
+sub job_results (_) { decode_json HGET cp . "job.$_[0]", 'results' }
+sub set_job_results ($+) { HSET cp . "job.$_[0]", 'results', encode_json $_[1] }
+sub job_inmeta (_) { decode_json HGET cp . "job.$_[0]", 'inmeta' }
+sub set_job_inmeta ($+) { HSET cp . "job.$_[0]", 'inmeta', encode_json $_[1] }
+sub problem_meta (_) { decode_json HGET cp . "problem.$_[0]", 'meta' }
+sub set_problem_meta ($+) { HSET cp . "problem.$_[0]", 'meta', encode_json $_[1] }
+sub job_daemon (_) { HGET cp . "job.$_[0]", 'daemon' }
+sub set_job_daemon ($$) { HSETNX cp . "job.$_[0]", 'daemon', $_[1] };
sub defhash{
my ($name, @keys) = @_;
SADD cp . $name, $key or return;
HMSET cp . "$name.$key", %values;
};
+ dynsub "remove_$name", sub (_) {
+ my $key = shift;
+ SREM cp . $name, $key;
+ };
+
dynsub "push_$name", sub {
my $nr = INCR cp . $name;
HMSET cp . "$name.$nr", @_;
our @EXPORT_OK = do {
no strict 'refs';
- grep { $_ =~ /^[a-z]/ and exists &$_ } keys %{__PACKAGE__ . '::'};
+ grep { $_ =~ /^[a-zA-Z]/ and exists &$_ } keys %{__PACKAGE__ . '::'};
};
1
declaregen 'Log::Entry' => qr,^${contest}log/$component/index$,;
declaregen Submit => qr,^${contest}submit$,;
declaregen Pb => qr,^${contest}pb/index$,;
- declaregen 'Pb::Entry' => qr,^${contest}pb/$component/index$,;
+ declaregen 'Pb::Entry' => qr,^${contest}pb/$component$,;
}
sub generate{
gzip \$page => "$path_noext.$lang.gz.$ext.new", Minimal => 1;
say $typemap "URI: $basename.$lang.gz.$ext\nContent-Language: $lang\nContent-Encoding: gzip\nContent-Type: " . CONTENT_TYPES->{$ext} . "\n";
}
+ last
}
for my $lang (@{LANGUAGES()}) {
use constant TITLE => 'Job log';
use constant PAGE_SIZE => 10;
+use constant FORMAT_EXTENSION => {
+ CPP => 'cpp',
+};
+
use HTML::Template::Compiled;
use POSIX qw/strftime/;
use Gruntmaster::Page::Common qw/header footer/;
-use Gruntmaster::Data qw/job_date job_file job_name job_private job_problem job_result job_result_text job_user/;
+use Gruntmaster::Data qw/job_date job_file problem_name job_private job_problem job_result job_result_text job_user/;
my %templates = (
en => <<'HTML',
<tr><th>ID<th>Problem<th>Date<th>Size<th>User<th>Result
<tbody>
<tmpl_loop log><tr><td><a href="<tmpl_var id>"><tmpl_var id></a>
-<td><a href="/pb/<tmpl_var problem>"><tmpl_var name></a>
+<td><a href="../pb/<tmpl_var problem>"><tmpl_var name></a>
<td><tmpl_var date>
-<td><tmpl_var size></a>
+<td><a href="src/<tmpl_var filename>"<tmpl_if private> data-private</tmpl_if>><tmpl_var size></a></a>
<td><tmpl_var user><td class="r<tmpl_var result>"><tmpl_var result_text>
</tmpl_loop>
</table>
id => $_,
(job_private() ? (private => job_private) : ()),
date => (job_date() ? strftime ('%c' => localtime job_date) : '?'),
- name => job_name,
+ name => problem_name job_problem,
problem => job_problem,
result => job_result,
result_text => job_result_text,
<tmpl_if levels>
<h2>Beginner</h2>
<ul>
-<tmpl_loop beginner><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop beginner><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Easy</h2>
<ul>
-<tmpl_loop easy><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop easy><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Medium</h2>
<ul>
-<tmpl_loop medium><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop medium><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<h2>Hard</h2>
<ul>
-<tmpl_loop hard><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop hard><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
<tmpl_else>
<ul>
-<tmpl_loop problems><li><a href="<tmpl_var id>"><tmpl_var name></a>
+<tmpl_loop problems><li><a href="<tmpl_var id>.var"><tmpl_var name></a>
</tmpl_loop></ul>
</tmpl_if>
HTML
$templates{$_} .= footer $_ for keys %templates;
sub generate{
- $_[0] =~ m,(?:ct/([^/])+/)?log/(\w+)\.html$,;
+ $_[0] =~ m,(?:ct/([^/])+/)?pb/(\w+)\.html$,;
my ($contest, $id) = ($1, $2);
my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
}
$htc->param(formats => FORMATS);
$htc->param(id => $id);
- local $Gruntmaster::Data::contest = ($_[0] =~ m,(?:ct/([^/])+/)?,)[0];
+ local $Gruntmaster::Data::contest = $contest if $contest;
$htc->param(name => problem_name $id);
- $htc->param(statement => problem_statement $id, $_[2]);
+ $htc->param(statement => problem_statement $id);
$htc->output
}