LP1932358 Serialize patron bucket entry batch deletion
authorBill Erickson <berickxx@gmail.com>
Tue, 3 Aug 2021 21:11:42 +0000 (17:11 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 12 Aug 2021 20:36:37 +0000 (16:36 -0400)
Avoid large sets of parallel patron bucket item delete calls by
serialzing the calls so they go one at a time.

Adds a progress meter to the display during delete.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Josh Stompro <stompro@stompro.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/templates/staff/circ/patron/bucket/t_view.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bucket/app.js

index 37cdaee..a5d6a9c 100644 (file)
@@ -1,3 +1,17 @@
+<!-- edit bucket dialog -->
+<style>
+progress {
+  text-align: center;
+  height: 25px;
+  width: 500px;
+  margin-bottom: 10px;
+}
+</style>
+
+<div ng-show='running'>
+  <progress max="{{progress.max}}" value="{{progress.count}}"></progress>
+</div>
+
 <eg-grid
   ng-hide="forbidden"
   features="allowAll,-display"
index 2c3d355..e183683 100644 (file)
@@ -789,19 +789,32 @@ function($scope,  $q , $routeParams , $timeout , $window , $uibModal , bucketSvc
     }
 
     $scope.detachUsers = function(users) {
-        var promises = [];
+        var promise = $q.when();
+
+        $scope.running = true;
+        $scope.progress = {
+            count: 0,
+            max: users.length
+        };
+
         angular.forEach(users, function(rec) {
             var item = bucketSvc.currentBucket.items().filter(
                 function(i) {
                     return (i.target_user() == rec.id)
                 }
             );
-            if (item.length)
-                promises.push(bucketSvc.detachUser(item[0].id()));
+            if (item.length) {
+                promise = promise.then(function() {
+                    return bucketSvc.detachUser(item[0].id())
+                    .then(function() { $scope.progress.count++; });
+                });
+            }
         });
 
         bucketSvc.bucketNeedsRefresh = true;
-        return $q.all(promises).then(drawBucket);
+        return promise
+            .then(function() { $scope.running = false; })
+            .then(drawBucket);
     }
 
     $scope.spawnUserEdit = function (users) {