From: Bill Erickson Date: Wed, 2 Dec 2020 21:52:47 +0000 (-0800) Subject: LP1896285 Patron search add to bucket serialize X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e7ff03cf0ae091aad1de2d6d615f47a2e70b5f7d;p=working%2FEvergreen.git LP1896285 Patron search add to bucket serialize Add a batch of patrons to a bucket one patron at a time to avoid overwhelming the server with bucket item create requests and potentially exhausing the open-ils.actor service. Signed-off-by: Bill Erickson Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 0b1a1a7d52..f60239850e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -633,24 +633,26 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore , if (recs.length == 0) return; var added_count = 0; var failed_count = 0; - var p = []; + var promise = $q.when(); angular.forEach(recs, function(rec) { var item = new egCore.idl.cubi(); item.bucket(data.id()); item.target_user(rec.id()); - p.push(egCore.net.request( - 'open-ils.actor', - 'open-ils.actor.container.item.create', - egCore.auth.token(), 'user', item - ).then( + promise = promise.then(function() { + return egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.container.item.create', + egCore.auth.token(), 'user', item + ); + }).then( function(){ added_count++ }, function(){ failed_count++ } - )); + ); } ); - $q.all(p).then( function () { + promise.then( function () { if (added_count) ngToast.create($interpolate(egCore.strings.BUCKET_ADD_SUCCESS)({ count: ''+added_count, name: data.name()} )); if (failed_count) ngToast.warning($interpolate(egCore.strings.BUCKET_ADD_FAIL)({ count: ''+failed_count, name: data.name() } )); });