[open-ils-commits] [GIT] Evergreen ILS branch rel_3_0 updated. e05cf34dd061463b10653c9e929a51e32e2bd7f9

Evergreen Git git at git.evergreen-ils.org
Wed May 23 16:41:43 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_3_0 has been updated
       via  e05cf34dd061463b10653c9e929a51e32e2bd7f9 (commit)
      from  2545bc37ac0e6ee1cc3bbf4e7632de6400ad29c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e05cf34dd061463b10653c9e929a51e32e2bd7f9
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Thu Apr 19 11:44:42 2018 -0400

    LP#1765444: improve how MARC editor fetches fixed field metadata
    
    This patch fixes a problem where the web staff MARC editor would
    make repeated and redundant calls to two Evergreen methods to fetch
    data about fixed field positions and values if that metadata was
    not already cached by local storage or Hatch.
    
    In particular, this patch caches and returns the data retrieval
    promises, ensuring that only one set of FF position and value
    requests are made.
    
    Prior to this patch, each eg-marc-edit-fixed-field directive, of which
    there are 64, could end up invoking those methods when initializing
    the editor for a record type that had not been previously seen.
    
    To test
    -------
    [1] Clear all FFPosTable_* and FFValueTable_* keys from local storage
        (or Hatch).
    [2] Retrieve a bib record in the web staff client. Note that up to
        64 calls each are made of open-ils.cat.biblio.fixed_field_values.by_rec_type
        and open-ils.fielder.cmfpm.atomic.
    [3] Apply the patch and repeat steps #1 and #2.
    [4] This time, note that only one call each are made.
    [5] Verify that the fixed field inputs continue to work as expected.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Cesar Velez <cesar.velez at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js
index dcc92be..85b2e32 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js
@@ -62,58 +62,64 @@ function($q,   egCore,   egAuth) {
         });
     };
 
+    var _ffpos_promises = {};
     service.fetchFFPosTable = function(rtype) {
-        var deferred = $q.defer();
+        if (!(rtype in _ffpos_promises)) {
+            _ffpos_promises[rtype] = $q.defer();
 
-        var hatch_pos_key = 'FFPosTable_'+rtype;
+            var hatch_pos_key = 'FFPosTable_'+rtype;
 
-        egCore.hatch.getItem(hatch_pos_key).then(function(cached_table) {
-            if (cached_table) {
-                service.ff_pos_map[rtype] = cached_table;
-                deferred.resolve(cached_table);
+            egCore.hatch.getItem(hatch_pos_key).then(function(cached_table) {
+                if (cached_table) {
+                    service.ff_pos_map[rtype] = cached_table;
+                    _ffpos_promises[rtype].resolve(cached_table);
 
-            } else {
+                } else {
 
-                egCore.net.request( // First, get the list of FFs (minus 006)
-                    'open-ils.fielder',
-                    'open-ils.fielder.cmfpm.atomic',
-                    { query : { tag : { '!=' : '006' } } }
-                ).then(function (data)  {
-                    service.ff_pos_map[rtype] = data;
-                    egCore.hatch.setItem(hatch_pos_key, data);
-                    deferred.resolve(data);
-                });
-            }
-        });
+                    egCore.net.request( // First, get the list of FFs (minus 006)
+                        'open-ils.fielder',
+                        'open-ils.fielder.cmfpm.atomic',
+                        { query : { tag : { '!=' : '006' } } }
+                    ).then(function (data)  {
+                        service.ff_pos_map[rtype] = data;
+                        egCore.hatch.setItem(hatch_pos_key, data);
+                        _ffpos_promises[rtype].resolve(data);
+                    });
+                }
+            });
+        }
 
-        return deferred.promise;
+        return _ffpos_promises[rtype].promise;
     };
 
+    var _ffval_promises = {};
     service.fetchFFValueTable = function(rtype) {
-        var deferred = $q.defer();
+        if (!(rtype in _ffval_promises)) {
+            _ffval_promises[rtype] = $q.defer();
 
-        var hatch_value_key = 'FFValueTable_'+rtype;
+            var hatch_value_key = 'FFValueTable_'+rtype;
 
-        egCore.hatch.getItem(hatch_value_key).then(function(cached_table) {
-            if (cached_table) {
-                service.ff_value_map[rtype] = cached_table;
-                deferred.resolve(cached_table);
+            egCore.hatch.getItem(hatch_value_key).then(function(cached_table) {
+                if (cached_table) {
+                    service.ff_value_map[rtype] = cached_table;
+                    _ffval_promises[rtype].resolve(cached_table);
 
-            } else {
+                } else {
 
-                egCore.net.request(
+                    egCore.net.request(
                         'open-ils.cat',
                         'open-ils.cat.biblio.fixed_field_values.by_rec_type',
                         rtype
-                ).then(function (data)  {
-                    service.ff_value_map[rtype] = data;
-                    egCore.hatch.setItem(hatch_value_key, data);
-                    deferred.resolve(data);
-                });
-            }
-        });
+                    ).then(function (data)  {
+                        service.ff_value_map[rtype] = data;
+                        egCore.hatch.setItem(hatch_value_key, data);
+                        _ffval_promises[rtype].resolve(data);
+                    });
+                }
+            });
+        }
 
-        return deferred.promise;
+        return _ffval_promises[rtype].promise;
     };
 
     service.loadRemoteTagTable = function(fields, tt_key) {

-----------------------------------------------------------------------

Summary of changes:
 .../js/ui/default/staff/cat/services/tagtable.js   |   84 +++++++++++---------
 1 files changed, 45 insertions(+), 39 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list