]>
Commit | Line | Data |
---|---|---|
1 | package Gruntmaster::Page::Log; | |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | use Gruntmaster::Page::Base log => 'Job log'; | |
7 | our @ISA = qw/Gruntmaster::Page::Base/; | |
8 | our $VERSION = '0.001'; | |
9 | ||
10 | use constant PAGE_SIZE => 10; | |
11 | ||
12 | sub _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 | ||
37 | sub max_age { 5 } | |
38 | ||
39 | 1 |