From 493d07a5f51f34f395da012b1aecd31b55e81a32 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 24 Jan 2014 19:13:18 +0200 Subject: [PATCH] Fix log pagination --- lib/Gruntmaster/Page/Log.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Gruntmaster/Page/Log.pm b/lib/Gruntmaster/Page/Log.pm index fce36cb..dddd86e 100644 --- a/lib/Gruntmaster/Page/Log.pm +++ b/lib/Gruntmaster/Page/Log.pm @@ -33,8 +33,8 @@ sub _generate{ my ($self, $htc, $path, $lang) = @_; $path =~ m,^(?:ct/([^/]+)/)?log/(\w+)\.html$,; - local $Gruntmaster::Data::contest = $1; - my $pages = jobcard / PAGE_SIZE; + local $Gruntmaster::Data::contest = $1 if $1; + my $pages = POSIX::ceil (jobcard / PAGE_SIZE); my $page = $2 eq 'index' ? $pages : $2; my @log = sort { $b->{id} <=> $a->{id} } map +{ @@ -47,7 +47,7 @@ sub _generate{ result => job_result, result_text => job_result_text, size => sprintf ("%.2f KiB", job_filesize() / 1024), - user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. $page == $pages ? jobcard : $page * PAGE_SIZE; + user => job_user}, ($page - 1) * PAGE_SIZE + 1 .. ($page == $pages ? jobcard : $page * PAGE_SIZE); $htc->param(log => \@log); } -- 2.39.2