From: Marius Gavrilescu Date: Mon, 27 Jan 2014 09:12:34 +0000 (+0200) Subject: Add log pagination, allow jo and fix bugs in log/log_entry X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=b83e43dc480771137fcff41589815556881b1243;p=plack-app-gruntmaster.git Add log pagination, allow jo and fix bugs in log/log_entry --- diff --git a/lib/Gruntmaster/Page/Log.pm b/lib/Gruntmaster/Page/Log.pm index cdef1df..2379e80 100644 --- a/lib/Gruntmaster/Page/Log.pm +++ b/lib/Gruntmaster/Page/Log.pm @@ -16,12 +16,15 @@ use constant TEMPLATES => { IDProblemDateSizeUserResult - + - data-private> + data-private> + +Prev page +Next page HTML }; @@ -30,7 +33,7 @@ sub _generate{ $path =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,; local $Gruntmaster::Data::contest = $1 if $1; - my $pages = POSIX::ceil (jobcard / PAGE_SIZE); + my $pages = POSIX::floor (jobcard / PAGE_SIZE); my $page = $2 eq 'index' ? $pages : $2; my @log = sort { $b->{id} <=> $a->{id} } map +{ @@ -45,6 +48,8 @@ sub _generate{ size => sprintf ("%.2f KiB", job_filesize() / 1024), user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE); $htc->param(log => \@log); + $htc->param(next => $page + 1) unless $page == $pages; + $htc->param(prev => $page - 1) unless $page == 1; } 1 diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index e20c891..a8abc12 100644 --- a/lib/Gruntmaster/Page/Log/Entry.pm +++ b/lib/Gruntmaster/Page/Log/Entry.pm @@ -26,10 +26,14 @@ sub _generate{ local $Gruntmaster::Data::contest = $1; my $id = $2; - my @tests = map { - $_->{time} = sprintf "%.4fs", $_->{time}; - $_ - } @{job_results $id}; + my @tests = (); + + eval { + @tests = map { + $_->{time} = sprintf "%.4fs", $_->{time}; + $_ + } @{job_results $id}; + }; $htc->param(id => $id); $htc->param(tests => \@tests);