Fix log pagination
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 24 Jan 2014 17:13:18 +0000 (19:13 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 24 Jan 2014 17:13:18 +0000 (19:13 +0200)
lib/Gruntmaster/Page/Log.pm

index fce36cbe8fe1a4f5d91b3082c528a9cb18060bcb..dddd86eb9883d18becb146ca90bd826f8a1fa0f9 100644 (file)
@@ -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);
 }
 
This page took 0.011047 seconds and 4 git commands to generate.