From b83e43dc480771137fcff41589815556881b1243 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 27 Jan 2014 11:12:34 +0200 Subject: [PATCH] Add log pagination, allow jo and fix bugs in log/log_entry --- lib/Gruntmaster/Page/Log.pm | 11 ++++++++--- lib/Gruntmaster/Page/Log/Entry.pm | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) 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); -- 2.39.2