From: Marius Gavrilescu Date: Fri, 24 Jan 2014 17:13:18 +0000 (+0200) Subject: Fix log pagination X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=493d07a5f51f34f395da012b1aecd31b55e81a32;p=gruntmaster-page.git Fix log pagination --- 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); }