TPAC: more intelligent detail paging #1
authorBill Erickson <berick@esilibrary.com>
Sat, 28 Apr 2012 18:12:53 +0000 (14:12 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 9 May 2012 14:02:07 +0000 (10:02 -0400)
Only fetch a small page of records at a time when generating the paging
links in the detail page.

Part 2 will be to repair the 'Last' record button in the staff client,
which will not work with this change.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/templates/opac/parts/record/body.tt2

index 48231d3..b10f312 100644 (file)
@@ -10,11 +10,6 @@ use Data::Dumper;
 $Data::Dumper::Indent = 0;
 my $U = 'OpenILS::Application::AppUtils';
 
-# when fetching "all" search results for staff client 
-# start/end paging, fetch this many IDs at most
-my $all_recs_limit = 10000;
-
-
 sub _prepare_biblio_search_basics {
     my ($cgi) = @_;
 
@@ -311,9 +306,9 @@ sub load_rresults {
     $ctx->{page_size} = $limit;
     $ctx->{search_page} = $page;
 
-    # fetch the first hit from the next page
+    # fetch this page plus the first hit from the next page
     if ($internal) {
-        $limit = $all_recs_limit;
+        $limit = $offset + $limit + 1;
         $offset = 0;
     }
 
@@ -580,7 +575,7 @@ sub marc_expert_search {
     return Apache2::Const::OK if @$query == 0;
 
     if ($args{internal}) {
-        $limit = $all_recs_limit;
+        $limit = $offset + $limit + 1;
         $offset = 0;
     }
 
index 577f7f9..b7efd51 100644 (file)
@@ -18,7 +18,8 @@
             [%
                 IF ctx.prev_search_record;
                     prev_args = {};
-                    IF ctx.search_result_index % (ctx.page_size + 1) == 0; # first record in the page
+                    IF ctx.search_page > 0 AND 
+                            ctx.search_result_index % ((ctx.page_size * ctx.search_page)) == 0; # first record in the page
                         prev_args.page = ctx.search_page - 1;
                     END;
                     ctx.prev_rec_url = mkurl(ctx.prev_search_record, prev_args, stop_parms);
@@ -30,7 +31,7 @@
             [% 
                 IF ctx.next_search_record;
                     next_args = {};
-                    IF ctx.page_size == ctx.search_result_index + 1;
+                    IF (ctx.page_size * (ctx.search_page + 1)) == ctx.search_result_index + 1;
                         next_args.page = ctx.search_page + 1;
                     END;
                     ctx.next_rec_url = mkurl(ctx.next_search_record, next_args, stop_parms);