From: Bill Erickson Date: Tue, 5 Feb 2019 20:35:51 +0000 (-0500) Subject: LP1761222 Holdings batch circ retrieval X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7e98d9071c7029289bf9fa008a85e7d852a26b13;p=Evergreen.git LP1761222 Holdings batch circ retrieval Fetch non-checked-in circulations for copies in the Holdings maintenance grid (for due date display) in batch instead firing a potentially vary large parallel batch of pcrud API calls. This also limits due date display to items that have open circulations, consistent with the XUL client. Signed-off-by: Bill Erickson Signed-off-by: Remington Steed Signed-off-by: Tiffany Little Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js index 78055cf402..73c91a350b 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js @@ -137,22 +137,29 @@ function(egCore , $q) { cp.copy_alert_count = cp.copy_alerts.filter(function(aca) { return aca.ack_time == null ;}).length; } else cp.copy_alert_count = 0; - - var copy_circ = egCore.pcrud.search('combcirc', { target_copy : cp.id }, - { - order_by : {combcirc : 'xact_start desc'}, - limit : 1 - } - ).then(function(copy_circ) { - if (copy_circ) { - cp._circ = egCore.idl.toHash(copy_circ, true); - cp._circ_lib = copy_circ.circ_lib(); - cp._duration = copy_circ.duration(); - } - return copy_circ; - }); }); + // Grab the open circulation (i.e. checkin_time=null) for + // all of the copies we're rendering so we can display + // due date info. There should only ever be one circulation + // at most with checkin_time=null for any copy. + var copyIds = svc.copies.map(function(cp) {return cp.id}) + .filter(function(id) {return Boolean(id)}); // avoid nulls + + egCore.pcrud.search('circ', + {target_copy: copyIds, checkin_time: null} + ).then( + null, // complete + null, // error + function(circ) { + var cp = svc.copies.filter(function(c) { + return c.id == circ.target_copy() })[0]; + cp._circ = egCore.idl.toHash(circ, true); + cp._circ_lib = circ.circ_lib(); + cp._duration = circ.duration(); + } + ); + // create a label using just the unique part of the owner list var index = 0; var prev_owner_list;