From: Mike Rylander Date: Wed, 27 Feb 2013 16:02:47 +0000 (-0500) Subject: Stamping upgrade scripts for Org Unit Proximity Adjustment and Custom Best-Hold Sort... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=cbf3c8636645af6b5831a40ff3f75c2fc5cf987f;p=evergreen%2Fmasslnc.git Stamping upgrade scripts for Org Unit Proximity Adjustment and Custom Best-Hold Sort Order Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 4f84162f23..a686ea55a7 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -87,7 +87,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 ('0758', :eg_version); -- jeff davis / miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0760', :eg_version); -- senator/miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0759.schema.org_prox_adjust.sql b/Open-ILS/src/sql/Pg/upgrade/0759.schema.org_prox_adjust.sql new file mode 100644 index 0000000000..a83a844bad --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0759.schema.org_prox_adjust.sql @@ -0,0 +1,126 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0759', :eg_version); + +CREATE TABLE actor.org_unit_proximity_adjustment ( + id SERIAL PRIMARY KEY, + item_circ_lib INT REFERENCES actor.org_unit (id), + item_owning_lib INT REFERENCES actor.org_unit (id), + copy_location INT REFERENCES asset.copy_location (id), + hold_pickup_lib INT REFERENCES actor.org_unit (id), + hold_request_lib INT REFERENCES actor.org_unit (id), + pos INT NOT NULL DEFAULT 0, + absolute_adjustment BOOL NOT NULL DEFAULT FALSE, + prox_adjustment NUMERIC, + circ_mod TEXT, -- REFERENCES config.circ_modifier (code), + CONSTRAINT prox_adj_criterium CHECK (COALESCE(item_circ_lib::TEXT,item_owning_lib::TEXT,copy_location::TEXT,hold_pickup_lib::TEXT,hold_request_lib::TEXT,circ_mod) IS NOT NULL) +); +CREATE UNIQUE INDEX prox_adj_once_idx ON actor.org_unit_proximity_adjustment (item_circ_lib,item_owning_lib,copy_location,hold_pickup_lib,hold_request_lib,circ_mod); +CREATE INDEX prox_adj_circ_lib_idx ON actor.org_unit_proximity_adjustment (item_circ_lib); +CREATE INDEX prox_adj_owning_lib_idx ON actor.org_unit_proximity_adjustment (item_owning_lib); +CREATE INDEX prox_adj_copy_location_idx ON actor.org_unit_proximity_adjustment (copy_location); +CREATE INDEX prox_adj_pickup_lib_idx ON actor.org_unit_proximity_adjustment (hold_pickup_lib); +CREATE INDEX prox_adj_request_lib_idx ON actor.org_unit_proximity_adjustment (hold_request_lib); +CREATE INDEX prox_adj_circ_mod_idx ON actor.org_unit_proximity_adjustment (circ_mod); + +CREATE OR REPLACE FUNCTION actor.org_unit_ancestors_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$ + WITH RECURSIVE org_unit_ancestors_distance(id, distance) AS ( + SELECT $1, 0 + UNION + SELECT ou.parent_ou, ouad.distance+1 + FROM actor.org_unit ou JOIN org_unit_ancestors_distance ouad ON (ou.id = ouad.id) + WHERE ou.parent_ou IS NOT NULL + ) + SELECT * FROM org_unit_ancestors_distance; +$$ LANGUAGE SQL STABLE ROWS 1; + +CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity( + ahr_id INT, + acp_id BIGINT, + copy_context_ou INT DEFAULT NULL + -- TODO maybe? hold_context_ou INT DEFAULT NULL. This would optionally + -- support an "ahprox" measurement: adjust prox between copy circ lib and + -- hold request lib, but I'm unsure whether to use this theoretical + -- argument only in the baseline calculation or later in the other + -- queries in this function. +) RETURNS NUMERIC AS $f$ +DECLARE + aoupa actor.org_unit_proximity_adjustment%ROWTYPE; + ahr action.hold_request%ROWTYPE; + acp asset.copy%ROWTYPE; + acn asset.call_number%ROWTYPE; + acl asset.copy_location%ROWTYPE; + baseline_prox NUMERIC; + + icl_list INT[]; + iol_list INT[]; + isl_list INT[]; + hpl_list INT[]; + hrl_list INT[]; + +BEGIN + + SELECT * INTO ahr FROM action.hold_request WHERE id = ahr_id; + SELECT * INTO acp FROM asset.copy WHERE id = acp_id; + SELECT * INTO acn FROM asset.call_number WHERE id = acp.call_number; + SELECT * INTO acl FROM asset.copy_location WHERE id = acp.location; + + IF copy_context_ou IS NULL THEN + copy_context_ou := acp.circ_lib; + END IF; + + -- First, gather the baseline proximity of "here" to pickup lib + SELECT prox INTO baseline_prox FROM actor.org_unit_proximity WHERE from_org = copy_context_ou AND to_org = ahr.pickup_lib; + + -- Find any absolute adjustments, and set the baseline prox to that + SELECT adj.* INTO aoupa + FROM actor.org_unit_proximity_adjustment adj + LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib) + LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location) + LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib) + LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib) + WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND + absolute_adjustment AND + COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL + ORDER BY + COALESCE(acp_cl.distance,999) + + COALESCE(acn_ol.distance,999) + + COALESCE(acl_ol.distance,999) + + COALESCE(ahr_pl.distance,999) + + COALESCE(ahr_rl.distance,999), + adj.pos + LIMIT 1; + + IF FOUND THEN + baseline_prox := aoupa.prox_adjustment; + END IF; + + -- Now find any relative adjustments, and change the baseline prox based on them + FOR aoupa IN + SELECT adj.* + FROM actor.org_unit_proximity_adjustment adj + LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib) + LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location) + LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib) + LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib) + WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND + NOT absolute_adjustment AND + COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL + LOOP + baseline_prox := baseline_prox + aoupa.prox_adjustment; + END LOOP; + + RETURN baseline_prox; +END; +$f$ LANGUAGE PLPGSQL; + +ALTER TABLE actor.org_unit_proximity_adjustment + ADD CONSTRAINT actor_org_unit_proximity_adjustment_circ_mod_fkey + FOREIGN KEY (circ_mod) REFERENCES config.circ_modifier (code) + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE action.hold_copy_map ADD COLUMN proximity NUMERIC; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/0760.schema.custom-best-hold-selection.sql b/Open-ILS/src/sql/Pg/upgrade/0760.schema.custom-best-hold-selection.sql new file mode 100644 index 0000000000..3cacb3dfc2 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0760.schema.custom-best-hold-selection.sql @@ -0,0 +1,150 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0760', :eg_version); + +CREATE TABLE config.best_hold_order( + id SERIAL PRIMARY KEY, -- (metadata) + name TEXT UNIQUE, -- i18n (metadata) + pprox INT, -- copy capture <-> pickup lib prox + hprox INT, -- copy circ lib <-> request lib prox + aprox INT, -- copy circ lib <-> pickup lib ADJUSTED prox on ahcm + approx INT, -- copy capture <-> pickup lib ADJUSTED prox from function + priority INT, -- group hold priority + cut INT, -- cut-in-line + depth INT, -- selection depth + htime INT, -- time since last home-lib circ exceeds org-unit setting + rtime INT, -- request time + shtime INT -- time since copy last trip home exceeds org-unit setting +); + +-- At least one of these columns must contain a non-null value +ALTER TABLE config.best_hold_order ADD CHECK (( + pprox IS NOT NULL OR + hprox IS NOT NULL OR + aprox IS NOT NULL OR + priority IS NOT NULL OR + cut IS NOT NULL OR + depth IS NOT NULL OR + htime IS NOT NULL OR + rtime IS NOT NULL +)); + +INSERT INTO config.best_hold_order ( + name, + pprox, aprox, priority, cut, depth, rtime, htime, hprox +) VALUES ( + 'Traditional', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO config.best_hold_order ( + name, + hprox, pprox, aprox, priority, cut, depth, rtime, htime +) VALUES ( + 'Traditional with Holds-always-go-home', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO config.best_hold_order ( + name, + htime, hprox, pprox, aprox, priority, cut, depth, rtime +) VALUES ( + 'Traditional with Holds-go-home', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO config.best_hold_order ( + name, + priority, cut, rtime, depth, pprox, hprox, aprox, htime +) VALUES ( + 'FIFO', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO config.best_hold_order ( + name, + hprox, priority, cut, rtime, depth, pprox, aprox, htime +) VALUES ( + 'FIFO with Holds-always-go-home', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO config.best_hold_order ( + name, + htime, priority, cut, rtime, depth, pprox, aprox, hprox +) VALUES ( + 'FIFO with Holds-go-home', + 1, 2, 3, 4, 5, 6, 7, 8 +); + +INSERT INTO permission.perm_list ( + id, code, description +) VALUES ( + 543, + 'ADMIN_HOLD_CAPTURE_SORT', + oils_i18n_gettext( + 543, + 'Allows a user to make changes to best-hold selection sort order', + 'ppl', + 'description' + ) +); + +INSERT INTO config.org_unit_setting_type ( + name, label, description, datatype, fm_class, update_perm, grp +) VALUES ( + 'circ.hold_capture_order', + oils_i18n_gettext( + 'circ.hold_capture_order', + 'Best-hold selection sort order', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.hold_capture_order', + 'Defines the sort order of holds when selecting a hold to fill using a given copy at capture time', + 'coust', + 'description' + ), + 'link', + 'cbho', + 543, + 'holds' +); + +INSERT INTO config.org_unit_setting_type ( + name, label, description, datatype, update_perm, grp +) VALUES ( + 'circ.hold_go_home_interval', + oils_i18n_gettext( + 'circ.hold_go_home_interval', + 'Max foreign-circulation time', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.hold_go_home_interval', + 'Time a copy can spend circulating away from its circ lib before returning there to fill a hold (if one exists there)', + 'coust', + 'description' + ), + 'interval', + 543, + 'holds' +); + +INSERT INTO actor.org_unit_setting ( + org_unit, name, value +) VALUES ( + (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), + 'circ.hold_go_home_interval', + '"6 months"' +); + +UPDATE actor.org_unit_setting SET + name = 'circ.hold_capture_order', + value = (SELECT id FROM config.best_hold_order WHERE name = 'FIFO') +WHERE + name = 'circ.holds_fifo' AND value ILIKE '%true%'; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_prox_adjust.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_prox_adjust.sql deleted file mode 100644 index 43876d80cd..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_prox_adjust.sql +++ /dev/null @@ -1,124 +0,0 @@ -BEGIN; - -CREATE TABLE actor.org_unit_proximity_adjustment ( - id SERIAL PRIMARY KEY, - item_circ_lib INT REFERENCES actor.org_unit (id), - item_owning_lib INT REFERENCES actor.org_unit (id), - copy_location INT REFERENCES asset.copy_location (id), - hold_pickup_lib INT REFERENCES actor.org_unit (id), - hold_request_lib INT REFERENCES actor.org_unit (id), - pos INT NOT NULL DEFAULT 0, - absolute_adjustment BOOL NOT NULL DEFAULT FALSE, - prox_adjustment NUMERIC, - circ_mod TEXT, -- REFERENCES config.circ_modifier (code), - CONSTRAINT prox_adj_criterium CHECK (COALESCE(item_circ_lib::TEXT,item_owning_lib::TEXT,copy_location::TEXT,hold_pickup_lib::TEXT,hold_request_lib::TEXT,circ_mod) IS NOT NULL) -); -CREATE UNIQUE INDEX prox_adj_once_idx ON actor.org_unit_proximity_adjustment (item_circ_lib,item_owning_lib,copy_location,hold_pickup_lib,hold_request_lib,circ_mod); -CREATE INDEX prox_adj_circ_lib_idx ON actor.org_unit_proximity_adjustment (item_circ_lib); -CREATE INDEX prox_adj_owning_lib_idx ON actor.org_unit_proximity_adjustment (item_owning_lib); -CREATE INDEX prox_adj_copy_location_idx ON actor.org_unit_proximity_adjustment (copy_location); -CREATE INDEX prox_adj_pickup_lib_idx ON actor.org_unit_proximity_adjustment (hold_pickup_lib); -CREATE INDEX prox_adj_request_lib_idx ON actor.org_unit_proximity_adjustment (hold_request_lib); -CREATE INDEX prox_adj_circ_mod_idx ON actor.org_unit_proximity_adjustment (circ_mod); - -CREATE OR REPLACE FUNCTION actor.org_unit_ancestors_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$ - WITH RECURSIVE org_unit_ancestors_distance(id, distance) AS ( - SELECT $1, 0 - UNION - SELECT ou.parent_ou, ouad.distance+1 - FROM actor.org_unit ou JOIN org_unit_ancestors_distance ouad ON (ou.id = ouad.id) - WHERE ou.parent_ou IS NOT NULL - ) - SELECT * FROM org_unit_ancestors_distance; -$$ LANGUAGE SQL STABLE ROWS 1; - -CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity( - ahr_id INT, - acp_id BIGINT, - copy_context_ou INT DEFAULT NULL - -- TODO maybe? hold_context_ou INT DEFAULT NULL. This would optionally - -- support an "ahprox" measurement: adjust prox between copy circ lib and - -- hold request lib, but I'm unsure whether to use this theoretical - -- argument only in the baseline calculation or later in the other - -- queries in this function. -) RETURNS NUMERIC AS $f$ -DECLARE - aoupa actor.org_unit_proximity_adjustment%ROWTYPE; - ahr action.hold_request%ROWTYPE; - acp asset.copy%ROWTYPE; - acn asset.call_number%ROWTYPE; - acl asset.copy_location%ROWTYPE; - baseline_prox NUMERIC; - - icl_list INT[]; - iol_list INT[]; - isl_list INT[]; - hpl_list INT[]; - hrl_list INT[]; - -BEGIN - - SELECT * INTO ahr FROM action.hold_request WHERE id = ahr_id; - SELECT * INTO acp FROM asset.copy WHERE id = acp_id; - SELECT * INTO acn FROM asset.call_number WHERE id = acp.call_number; - SELECT * INTO acl FROM asset.copy_location WHERE id = acp.location; - - IF copy_context_ou IS NULL THEN - copy_context_ou := acp.circ_lib; - END IF; - - -- First, gather the baseline proximity of "here" to pickup lib - SELECT prox INTO baseline_prox FROM actor.org_unit_proximity WHERE from_org = copy_context_ou AND to_org = ahr.pickup_lib; - - -- Find any absolute adjustments, and set the baseline prox to that - SELECT adj.* INTO aoupa - FROM actor.org_unit_proximity_adjustment adj - LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) - LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib) - LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location) - LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib) - LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib) - WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND - absolute_adjustment AND - COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL - ORDER BY - COALESCE(acp_cl.distance,999) - + COALESCE(acn_ol.distance,999) - + COALESCE(acl_ol.distance,999) - + COALESCE(ahr_pl.distance,999) - + COALESCE(ahr_rl.distance,999), - adj.pos - LIMIT 1; - - IF FOUND THEN - baseline_prox := aoupa.prox_adjustment; - END IF; - - -- Now find any relative adjustments, and change the baseline prox based on them - FOR aoupa IN - SELECT adj.* - FROM actor.org_unit_proximity_adjustment adj - LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) - LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib) - LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location) - LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib) - LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib) - WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND - NOT absolute_adjustment AND - COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL - LOOP - baseline_prox := baseline_prox + aoupa.prox_adjustment; - END LOOP; - - RETURN baseline_prox; -END; -$f$ LANGUAGE PLPGSQL; - -ALTER TABLE actor.org_unit_proximity_adjustment - ADD CONSTRAINT actor_org_unit_proximity_adjustment_circ_mod_fkey - FOREIGN KEY (circ_mod) REFERENCES config.circ_modifier (code) - DEFERRABLE INITIALLY DEFERRED; - -ALTER TABLE action.hold_copy_map ADD COLUMN proximity NUMERIC; - -COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXYY.schema.custom-best-hold-selection.sql b/Open-ILS/src/sql/Pg/upgrade/XXYY.schema.custom-best-hold-selection.sql deleted file mode 100644 index 55e390682f..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXYY.schema.custom-best-hold-selection.sql +++ /dev/null @@ -1,148 +0,0 @@ -BEGIN; - -CREATE TABLE config.best_hold_order( - id SERIAL PRIMARY KEY, -- (metadata) - name TEXT UNIQUE, -- i18n (metadata) - pprox INT, -- copy capture <-> pickup lib prox - hprox INT, -- copy circ lib <-> request lib prox - aprox INT, -- copy circ lib <-> pickup lib ADJUSTED prox on ahcm - approx INT, -- copy capture <-> pickup lib ADJUSTED prox from function - priority INT, -- group hold priority - cut INT, -- cut-in-line - depth INT, -- selection depth - htime INT, -- time since last home-lib circ exceeds org-unit setting - rtime INT, -- request time - shtime INT -- time since copy last trip home exceeds org-unit setting -); - --- At least one of these columns must contain a non-null value -ALTER TABLE config.best_hold_order ADD CHECK (( - pprox IS NOT NULL OR - hprox IS NOT NULL OR - aprox IS NOT NULL OR - priority IS NOT NULL OR - cut IS NOT NULL OR - depth IS NOT NULL OR - htime IS NOT NULL OR - rtime IS NOT NULL -)); - -INSERT INTO config.best_hold_order ( - name, - pprox, aprox, priority, cut, depth, rtime, htime, hprox -) VALUES ( - 'Traditional', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO config.best_hold_order ( - name, - hprox, pprox, aprox, priority, cut, depth, rtime, htime -) VALUES ( - 'Traditional with Holds-always-go-home', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO config.best_hold_order ( - name, - htime, hprox, pprox, aprox, priority, cut, depth, rtime -) VALUES ( - 'Traditional with Holds-go-home', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO config.best_hold_order ( - name, - priority, cut, rtime, depth, pprox, hprox, aprox, htime -) VALUES ( - 'FIFO', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO config.best_hold_order ( - name, - hprox, priority, cut, rtime, depth, pprox, aprox, htime -) VALUES ( - 'FIFO with Holds-always-go-home', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO config.best_hold_order ( - name, - htime, priority, cut, rtime, depth, pprox, aprox, hprox -) VALUES ( - 'FIFO with Holds-go-home', - 1, 2, 3, 4, 5, 6, 7, 8 -); - -INSERT INTO permission.perm_list ( - id, code, description -) VALUES ( - 543, - 'ADMIN_HOLD_CAPTURE_SORT', - oils_i18n_gettext( - 543, - 'Allows a user to make changes to best-hold selection sort order', - 'ppl', - 'description' - ) -); - -INSERT INTO config.org_unit_setting_type ( - name, label, description, datatype, fm_class, update_perm, grp -) VALUES ( - 'circ.hold_capture_order', - oils_i18n_gettext( - 'circ.hold_capture_order', - 'Best-hold selection sort order', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'circ.hold_capture_order', - 'Defines the sort order of holds when selecting a hold to fill using a given copy at capture time', - 'coust', - 'description' - ), - 'link', - 'cbho', - 543, - 'holds' -); - -INSERT INTO config.org_unit_setting_type ( - name, label, description, datatype, update_perm, grp -) VALUES ( - 'circ.hold_go_home_interval', - oils_i18n_gettext( - 'circ.hold_go_home_interval', - 'Max foreign-circulation time', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'circ.hold_go_home_interval', - 'Time a copy can spend circulating away from its circ lib before returning there to fill a hold (if one exists there)', - 'coust', - 'description' - ), - 'interval', - 543, - 'holds' -); - -INSERT INTO actor.org_unit_setting ( - org_unit, name, value -) VALUES ( - (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), - 'circ.hold_go_home_interval', - '"6 months"' -); - -UPDATE actor.org_unit_setting SET - name = 'circ.hold_capture_order', - value = (SELECT id FROM config.best_hold_order WHERE name = 'FIFO') -WHERE - name = 'circ.holds_fifo' AND value ILIKE '%true%'; - -COMMIT;