LP#1777207: more tweaks collab/gmcharlt/lp1777207_circ_grid_performance
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 18 Jul 2019 15:27:35 +0000 (11:27 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 18 Jul 2019 15:27:50 +0000 (11:27 -0400)
[1] Reset sort options during a prepend() is now unconditional.
[2] Removed a grid.collect() that's unnecessary under certain
    circumstances.
[3] Edited the comments.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 120690a..965529b 100644 (file)
@@ -236,9 +236,9 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
             if ($scope.trim_list && checkinSvc.checkins.length > 20) {
                 //cut array short at 20 items
                 checkinSvc.checkins.length = 20;
-                checkinGrid.prepend(true, 20);
+                checkinGrid.prepend(20);
             } else {
-                checkinGrid.prepend(true);
+                checkinGrid.prepend();
             }
         },
         function() {
index cc0f82c..d79811c 100644 (file)
@@ -189,7 +189,7 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         };
 
         $scope.checkouts.unshift(row_item);
-        $scope.gridDataProvider.prepend(true);
+        $scope.gridDataProvider.prepend();
 
         egCore.hatch.setItem('circ.checkout.strict_barcode', $scope.strict_barcode);
         var options = {check_barcode : $scope.strict_barcode};
index e4bc86a..3998abb 100644 (file)
@@ -339,8 +339,8 @@ angular.module('egGridMod',
                     grid.collect();
                 }
 
-                controls.prepend = function(resetSort, limit) {
-                    grid.prepend(resetSort, limit);
+                controls.prepend = function(limit) {
+                    grid.prepend(limit);
                 }
 
                 controls.setLimit = function(limit,forget) {
@@ -1327,21 +1327,18 @@ angular.module('egGridMod',
                 });
             }
 
-            grid.prepend = function(resetSort, limit) {
+            grid.prepend = function(limit) {
                 var ran_into_duplicate = false;
                 var sort = grid.dataProvider.sort;
                 if (sort && sort.length) {
-                    // if sorting is in effect, we have no
-                    // have no way here of knowing which row
-                    // was most recently added nor that it
-                    // belongs on top of the visible set of rows,
-                    // so we default to a full collect()
-                    if (resetSort) { // and offset
-                        grid.dataProvider.sort = [];
-                        grid.offset = 0;
-                    }
-                    grid.collect();
-                    return;
+                    // If sorting is in effect, we have no way
+                    // of knowing that the new item should be
+                    // visible _if the sort order is retained_.
+                    // However, since the grids that do prepending in
+                    // the first place are ones where we always
+                    // want the new row to show up on top, we'll
+                    // remove the current sort options.
+                    grid.dataProvider.sort = [];
                 }
                 if (grid.offset > 0) {
                     // if we're prepending, we're forcing the
@@ -1354,6 +1351,10 @@ angular.module('egGridMod',
                 if (grid.collecting) return; // avoid parallel collect() or prepend()
                 grid.collecting = true;
                 console.debug('egGrid.prepend() starting');
+                // Note that we can count on the most-recently added
+                // item being at offset 0 in the data provider only
+                // for arrayNotifier data sources that do not have
+                // sort options currently set.
                 grid.dataProvider.get(0, 1).then(
                 null,
                 null,