[open-ils-commits] [GIT] Evergreen ILS branch rel_3_1 updated. cbe09037cf0829ca2516b8c1730df6099fbeb138

Evergreen Git git at git.evergreen-ils.org
Tue Sep 18 14:59:07 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_1 has been updated
       via  cbe09037cf0829ca2516b8c1730df6099fbeb138 (commit)
       via  9f9f4227db564d59720a83a62925d857e5ae70c7 (commit)
       via  4dd0d0cca13f199a1d05ac8e5990e54d287fb1e4 (commit)
       via  35c1958ef4500e7f1d67413a2e1694db7c5ab492 (commit)
      from  8b3656d02ca457639a4b52d42dc142a845fca4e2 (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 cbe09037cf0829ca2516b8c1730df6099fbeb138
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Tue Sep 18 14:53:47 2018 -0400

    LP#1787274: Stamping upgrade script for no dupe transits
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>
    
    Conflicts:
    	Open-ILS/src/sql/Pg/002.schema.config.sql

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 3b0a672..581d873 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1130', :eg_version); -- Dyrcona/mmorgan/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1133', :eg_version); -- berick/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql b/Open-ILS/src/sql/Pg/upgrade/1133.schema.no-dupe-transits.sql
similarity index 97%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql
rename to Open-ILS/src/sql/Pg/upgrade/1133.schema.no-dupe-transits.sql
index 0016a42..7faa26a 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1133.schema.no-dupe-transits.sql
@@ -1,7 +1,7 @@
 
 BEGIN;
 
---SELECT evergreen.upgrade_deps_block_check('XXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('1133', :eg_version);
 
 \qecho Applying a unique constraint to action.transit_copy.  This will
 \qecho only effect newly created transits.  Admins are encouraged to manually 

commit 9f9f4227db564d59720a83a62925d857e5ae70c7
Author: Bill Erickson <berickxx at gmail.com>
Date:   Tue Sep 18 11:21:26 2018 -0400

    LP#1787274 One active transit pgtap tests
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg b/Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg
new file mode 100644
index 0000000..41ec628
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg
@@ -0,0 +1,39 @@
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(6);
+
+-- Run the tests.
+
+PREPARE insert_transit AS    
+    INSERT INTO action.transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 0);
+
+PREPARE insert_hold_transit AS
+    INSERT INTO action.hold_transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
+
+PREPARE insert_reservation_transit AS
+    INSERT INTO action.reservation_transit_copy
+    (target_copy, source, dest, copy_status) VALUES (4003, 4, 7, 8);
+
+SELECT lives_ok('insert_transit', 'First transit inserts OK');
+
+SELECT is(
+    (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
+    1, 'Confirm a single transit exists'); 
+
+SELECT throws_ok('insert_transit');
+
+SELECT throws_ok('insert_hold_transit');
+
+SELECT throws_ok('insert_reservation_transit');
+
+SELECT is(
+    (SELECT COUNT(*) FROM action.transit_copy WHERE target_copy = 4003)::INT, 
+    1, 'Confirm a single transit exists'); 
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;

commit 4dd0d0cca13f199a1d05ac8e5990e54d287fb1e4
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Sep 17 18:16:42 2018 -0400

    LP#1787274 Active copy transit unique constraint
    
    Adds constraint triggers to action.*transit_copy tables to prevent
    creation of new transits for a copies when an existing transit of any
    type exists for the copy with a NULL dest_recv_time and cancel_time
    values (i.e. an open transit).
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 2fb3659..f766e86 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -552,7 +552,28 @@ CREATE TABLE action.transit_copy (
 CREATE INDEX active_transit_dest_idx ON "action".transit_copy (dest); 
 CREATE INDEX active_transit_source_idx ON "action".transit_copy (source);
 CREATE INDEX active_transit_cp_idx ON "action".transit_copy (target_copy);
+CREATE INDEX active_transit_for_copy ON action.transit_copy (target_copy)
+    WHERE dest_recv_time IS NULL AND cancel_time IS NULL;
 
+-- Check for duplicate transits across all transit types
+CREATE OR REPLACE FUNCTION action.copy_transit_is_unique() 
+    RETURNS TRIGGER AS $func$
+BEGIN
+    PERFORM * FROM action.transit_copy 
+        WHERE target_copy = NEW.target_copy 
+              AND dest_recv_time IS NULL 
+              AND cancel_time IS NULL;
+
+    IF FOUND THEN
+        RAISE EXCEPTION 'Copy id=% is already in transit', NEW.target_copy;
+    END IF;
+    RETURN NULL;
+END;
+$func$ LANGUAGE PLPGSQL STABLE;
+
+CREATE CONSTRAINT TRIGGER transit_copy_is_unique_check
+    AFTER INSERT ON action.transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
 
 CREATE TABLE action.hold_transit_copy (
 	hold	INT	REFERENCES action.hold_request (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
@@ -564,6 +585,10 @@ CREATE INDEX active_hold_transit_source_idx ON "action".hold_transit_copy (sourc
 CREATE INDEX active_hold_transit_cp_idx ON "action".hold_transit_copy (target_copy);
 CREATE INDEX hold_transit_copy_hold_idx on action.hold_transit_copy (hold);
 
+CREATE CONSTRAINT TRIGGER hold_transit_copy_is_unique_check
+    AFTER INSERT ON action.hold_transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
+
 
 CREATE TABLE action.unfulfilled_hold_list (
 	id		BIGSERIAL			PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/095.schema.booking.sql b/Open-ILS/src/sql/Pg/095.schema.booking.sql
index 453057b..974f3b9 100644
--- a/Open-ILS/src/sql/Pg/095.schema.booking.sql
+++ b/Open-ILS/src/sql/Pg/095.schema.booking.sql
@@ -166,4 +166,8 @@ CREATE INDEX active_reservation_transit_dest_idx ON "action".reservation_transit
 CREATE INDEX active_reservation_transit_source_idx ON "action".reservation_transit_copy (source);
 CREATE INDEX active_reservation_transit_cp_idx ON "action".reservation_transit_copy (target_copy);
 
+CREATE CONSTRAINT TRIGGER reservation_transit_copy_is_unique_check
+    AFTER INSERT ON action.reservation_transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
+
 COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql
new file mode 100644
index 0000000..0016a42
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-dupe-transits.sql
@@ -0,0 +1,73 @@
+
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXX', :eg_version);
+
+\qecho Applying a unique constraint to action.transit_copy.  This will
+\qecho only effect newly created transits.  Admins are encouraged to manually 
+\qecho remove any existing duplicate transits by applying values for cancel_time
+\qecho or dest_recv_time, or by deleting the offending transits. Below is a
+\qecho query to locate duplicate transits.  Note dupes may exist accross
+\qecho parent (action.transit_copy) and child tables (action.hold_transit_copy,
+\qecho action.reservation_transit_copy)
+\qecho 
+\qecho    WITH dupe_transits AS (
+\qecho        SELECT COUNT(*), target_copy FROM action.transit_copy
+\qecho        WHERE dest_recv_time IS NULL AND cancel_time IS NULL
+\qecho        GROUP BY 2 HAVING COUNT(*) > 1
+\qecho    ) SELECT atc.* 
+\qecho        FROM dupe_transits
+\qecho        JOIN action.transit_copy atc USING (target_copy)
+\qecho        WHERE dest_recv_time IS NULL AND cancel_time IS NULL;
+\qecho
+
+/* 
+Unique indexes are not inherited by child tables, so they will not prevent
+duplicate inserts on action.transit_copy and action.hold_transit_copy,
+for example.  Use check constraints instead to enforce unique-per-copy
+transits accross all transit types.
+*/
+
+-- Create an index for speedy check constraint lookups.
+CREATE INDEX active_transit_for_copy 
+    ON action.transit_copy (target_copy)
+    WHERE dest_recv_time IS NULL AND cancel_time IS NULL;
+
+-- Check for duplicate transits across all transit types
+CREATE OR REPLACE FUNCTION action.copy_transit_is_unique() 
+    RETURNS TRIGGER AS $func$
+BEGIN
+    PERFORM * FROM action.transit_copy 
+        WHERE target_copy = NEW.target_copy 
+              AND dest_recv_time IS NULL 
+              AND cancel_time IS NULL;
+    IF FOUND THEN
+        RAISE EXCEPTION 'Copy id=% is already in transit', NEW.target_copy;
+    END IF;
+    RETURN NULL;
+END;
+$func$ LANGUAGE PLPGSQL STABLE;
+
+-- Apply constraint to all transit tables
+CREATE CONSTRAINT TRIGGER transit_copy_is_unique_check
+    AFTER INSERT ON action.transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
+
+CREATE CONSTRAINT TRIGGER hold_transit_copy_is_unique_check
+    AFTER INSERT ON action.hold_transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
+
+CREATE CONSTRAINT TRIGGER reservation_transit_copy_is_unique_check
+    AFTER INSERT ON action.reservation_transit_copy
+    FOR EACH ROW EXECUTE PROCEDURE action.copy_transit_is_unique();
+
+/*
+-- UNDO
+DROP TRIGGER transit_copy_is_unique_check ON action.transit_copy;
+DROP TRIGGER hold_transit_copy_is_unique_check ON action.hold_transit_copy;
+DROP TRIGGER reservation_transit_copy_is_unique_check ON action.reservation_transit_copy;
+DROP INDEX action.active_transit_for_copy;
+*/
+
+COMMIT;
+

commit 35c1958ef4500e7f1d67413a2e1694db7c5ab492
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Sep 17 18:16:28 2018 -0400

    LP#1787274 Prevent multiple active copy checkins
    
    In the staff client checkin service, track which copies are currently
    in-flight to the checkin API call and prevent additional checkin API
    calls for any copy that is currently in flight.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js
index 69d26f8..bd88fec 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js
@@ -19,7 +19,8 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
             hold_shelf_slip : false,
             hold_transit_slip : false,
             transit_slip : false
-        }
+        },
+        in_flight_checkins: {}
     };
 
     egCore.startup.go().finally(function() {
@@ -266,10 +267,20 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                 var method = 'open-ils.circ.checkin';
                 if (options.override) method += '.override';
 
+                // Multiple checkin API calls should never be active
+                // for a single barcode.
+                if (service.in_flight_checkins[barcode]) {
+                    console.error('Barcode ' + barcode 
+                        + ' is already in flight for checkin, skipping');
+                    return $q.reject();
+                }
+                service.in_flight_checkins[barcode] = true;
+
                 return egCore.net.request(
                     'open-ils.circ', method, egCore.auth.token(), params
 
                 ).then(function(evt) {
+                    delete service.in_flight_checkins[barcode];
 
                     if (!angular.isArray(evt)) evt = [evt];
                     return service.flesh_response_data(
@@ -280,7 +291,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
                     .then(function(final_resp) {
                         return service.munge_resp_data(final_resp,'checkin',method)
                     })
-                });
+                }, function() {delete service.in_flight_checkins[barcode]});
             });
         });
     }

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/090.schema.action.sql          |   25 +++++++
 Open-ILS/src/sql/Pg/095.schema.booking.sql         |    4 +
 .../sql/Pg/live_t/lp1787274-no-dupe-transits.pg    |   39 +++++++++++
 .../Pg/upgrade/1133.schema.no-dupe-transits.sql    |   73 ++++++++++++++++++++
 .../web/js/ui/default/staff/circ/services/circ.js  |   15 ++++-
 6 files changed, 155 insertions(+), 3 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/live_t/lp1787274-no-dupe-transits.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/1133.schema.no-dupe-transits.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list