LP#1745499 Patron bucket from file query consolidation
authorBill Erickson <berickxx@gmail.com>
Thu, 25 Jan 2018 22:57:32 +0000 (17:57 -0500)
committerJason Stephenson <jason@sigio.com>
Sun, 18 Feb 2018 15:55:02 +0000 (10:55 -0500)
Replace one-pcrud-call-per-barcode with a single (streaming) pcrud
search call to fetch patron cards when using the barcode file upload
option in the web staff pending patron bucket UI.  This avoids spawning
high number of pcrud processes.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/web/js/ui/default/staff/circ/patron/bucket/app.js

index 4c3e5cc..70025b5 100644 (file)
@@ -220,24 +220,28 @@ function($scope,  $routeParams,  bucketSvc , egGridDataProvider,   egCore , ngTo
 
     $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
         if (newVal && newVal != oldVal) {
-            var promises = [];
+            var barcodes = [];
             // $scope.resetPendingList(); // ??? Add instead of replace
             angular.forEach(newVal.split(/\n/), function(line) {
                 if (!line) return;
                 // scrub any trailing spaces or commas from the barcode
                 line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
-                promises.push(egCore.pcrud.search(
-                    'ac',
-                    {barcode : line},
-                    {}
-                ).then(null, null, function(card) {
-                    bucketSvc.pendingList.push(card.usr());
-                }));
-            });
+                barcodes.push(line);
 
-            $q.all(promises).then(function () {
-                $scope.gridControls.setQuery({id : bucketSvc.pendingList});
             });
+            egCore.pcrud.search(
+                'ac',
+                {barcode : barcodes},
+                {}
+            ).then(
+                function() {
+                    $scope.gridControls.setQuery({id : bucketSvc.pendingList});
+                },
+                null, 
+                function(card) {
+                    bucketSvc.pendingList.push(card.usr());
+                }
+            );
         }
     });