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