From: miker Date: Sat, 2 Oct 2010 15:47:28 +0000 (+0000) Subject: configurable chunking of the holds stream to avoid the xulrunner "I forgot the chunke... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0808d66a3d793b8fe8544a6980aaf09e17a51373;p=evergreen%2Fpines.git configurable chunking of the holds stream to avoid the xulrunner "I forgot the chunked stream" problem git-svn-id: svn://svn.open-ils.org/ILS/trunk@18136 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 143caeb417..7b37e28a5b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -1341,6 +1341,9 @@ sub print_hold_pull_list_stream { delete($$params{org_id}) unless (int($$params{org_id})); delete($$params{limit}) unless (int($$params{limit})); delete($$params{offset}) unless (int($$params{offset})); + delete($$params{chunk_size}) unless (int($$params{chunk_size})); + delete($$params{chunk_size}) if ($$params{chunk_size} && $$params{chunk_size} > 50); # keep the size reasonable + $$params{chunk_size} ||= 10; $$params{org_id} = (defined $$params{org_id}) ? $$params{org_id}: $e->requestor->ws_ou; return $e->die_event unless $e->allowed('VIEW_HOLD', $$params{org_id }); @@ -1409,21 +1412,28 @@ sub print_hold_pull_list_stream { $logger->info("about to stream back " . scalar(@$holds_ids) . " holds"); - $client->respond( - $e->retrieve_action_hold_request([ + my @chunk; + for my $hid (@$holds_ids) { + push @chunk, $e->retrieve_action_hold_request([ $_->{"id"}, { "flesh" => 3, "flesh_fields" => { "ahr" => ["usr", "current_copy"], + "au" => ["card"], "acp" => ["location", "call_number"], "acn" => ["record"] } } - ]) - ) foreach @$holds_ids; + ]); + if (@chunk >= $$params{chunk_size}) { + $client->respond( \@chunk ); + @chunk = (); + } + } + $client->respond_complete( \@chunk ) if (@chunk); $e->disconnect; - undef; + return undef; } diff --git a/Open-ILS/web/opac/extras/circ/alt_pull_list.html b/Open-ILS/web/opac/extras/circ/alt_pull_list.html index 6302ac2704..c85fcf8047 100644 --- a/Open-ILS/web/opac/extras/circ/alt_pull_list.html +++ b/Open-ILS/web/opac/extras/circ/alt_pull_list.html @@ -61,42 +61,44 @@ { async : true, params: [ user.authtoken, - { org_id : cgi.param('o'), - limit : cgi.param('limit'), - offset : cgi.param('offset'), - sort : sort_order + { org_id : cgi.param('o'), + limit : cgi.param('limit'), + offset : cgi.param('offset'), + chunk_size : cgi.param('chunk_size'), + sort : sort_order } ], onresponse : function (r) { - var hold_fm = openils.Util.readResponse(r); - - // hashify the hold - var hold = hold_fm.toHash(true); - hold.current_copy = hold_fm.current_copy().toHash(true); - hold.current_copy.location = hold_fm.current_copy().location().toHash(true); - hold.current_copy.call_number = hold_fm.current_copy().call_number().toHash(true); - hold.current_copy.call_number.record = hold_fm.current_copy().call_number().record().toHash(true); - - // clone the template's html - var tr = dojo.clone( - dojo.query("tr", dojo.byId('template'))[0] - ); - dojo.query("td:not([type])", tr).forEach( - function(td) { - td.innerHTML = - dojo.string.substitute(td.innerHTML, hold); - } - ); - - new openils.BibTemplate({ - root : tr, - xml : dojox.xml.parser.parse(hold.current_copy.call_number.record.marc), - delay: false + dojo.forEach( openils.Util.readResponse(r), function (hold_fm) { + + // hashify the hold + var hold = hold_fm.toHash(true); + hold.usr = hold_fm.usr().toHash(true); + hold.usr.card = hold_fm.usr().card().toHash(true); + hold.current_copy = hold_fm.current_copy().toHash(true); + hold.current_copy.location = hold_fm.current_copy().location().toHash(true); + hold.current_copy.call_number = hold_fm.current_copy().call_number().toHash(true); + hold.current_copy.call_number.record = hold_fm.current_copy().call_number().record().toHash(true); + + // clone the template's html + var tr = dojo.clone( + dojo.query("tr", dojo.byId('template'))[0] + ); + dojo.query("td:not([type])", tr).forEach( + function(td) { + td.innerHTML = + dojo.string.substitute(td.innerHTML, hold); + } + ); + + new openils.BibTemplate({ + root : tr, + xml : dojox.xml.parser.parse(hold.current_copy.call_number.record.marc), + delay: false + }); + + dojo.place(tr, "target"); }); - - dojo.place(tr, "target"); - - }, oncomplete : function () { progress_dialog.hide(); window.print() }