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 });
$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;
}
{ 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() }