]> iEval git - plack-app-gruntmaster.git/blame_incremental - lib/Gruntmaster/Page/Log.pm
Make contest problem entries more cacheable
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Log.pm
... / ...
CommitLineData
1package Gruntmaster::Page::Log;
2
3use 5.014000;
4use strict;
5use warnings;
6use Gruntmaster::Page::Base log => 'Job log';
7our @ISA = qw/Gruntmaster::Page::Base/;
8our $VERSION = '0.001';
9
10use constant PAGE_SIZE => 10;
11
12sub _generate{
13 my ($self, $htc, $lang, $env, $ct, $page) = @_;
14 debug $env => "language is '$lang', contest is '$ct' and page is '$page'";
15 local $Gruntmaster::Data::contest = $ct if $ct;
16
17 my $pages = POSIX::floor (jobcard / PAGE_SIZE);
18 $pages ||= 1;
19 $page ||= $pages;
20
21 my @log = sort { $b->{id} <=> $a->{id} } map +{
22 id => $_,
23 (job_private() ? (private => job_private) : ()),
24 date => (job_date() ? strftime ('%c' => localtime job_date) : '?'),
25 extension => job_extension,
26 name => problem_name job_problem,
27 problem => job_problem,
28 result => job_result,
29 result_text => job_result_text,
30 size => sprintf ("%.2f KiB", job_filesize() / 1024),
31 user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE);
32 $htc->param(log => \@log);
33 $htc->param(next => $page + 1) unless $page == $pages;
34 $htc->param(prev => $page - 1) unless $page == 1;
35}
36
37sub max_age { 5 }
38
391
This page took 0.020639 seconds and 4 git commands to generate.