From: Lebbeous Fogle-Weekley Date: Mon, 17 Dec 2012 23:06:07 +0000 (-0500) Subject: fixes, approx, etc X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=763d60f46c8bda161bf486777e6f30e40ee2537b;p=evergreen%2Fequinox.git fixes, approx, etc Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 50db1da0bc..d243efddd6 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2304,6 +2304,32 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 32a519c671..05dedcf629 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -20,9 +20,9 @@ my $U = "OpenILS::Application::AppUtils"; # used in build_hold_sort_clause() my %HOLD_SORT_ORDER_BY = ( pprox => 'p.prox', - hprox => 'actor.org_unit_proximity(%d, h.request_lib)', + hprox => 'actor.org_unit_proximity(%d, h.request_lib)', # $cp->circ_lib aprox => 'COALESCE(hm.proximity, p.prox)', - approx => 'action.hold_copy_calculated_proximity(h.id, %d, %d)', + approx => 'action.hold_copy_calculated_proximity(h.id, %d, %d)', # $cp,$here priority => 'pgt.hold_priority', cut => 'CASE WHEN h.cut_in_line IS TRUE THEN 0 ELSE 1 END', depth => 'h.selection_depth', @@ -476,7 +476,7 @@ sub nearest_hold { local $OpenILS::Application::Storage::WRITE = 1; - my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $here, $cp->id, $age); + my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp->circ_lib, $here, $cp->id, $age); WITH go_home_interval AS ( SELECT OILS_JSON_TO_TEXT( (SELECT value FROM actor.org_unit_ancestor_setting( diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index bb42fbec34..cc9c48696d 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -1008,11 +1008,13 @@ CREATE TABLE config.best_hold_order( 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 + 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 diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 3f7bb6f6de..fd82cf0281 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -973,7 +973,16 @@ query-based fieldsets. Returns NULL if successful, or an error message if not. $$; -CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity(ahr_id INT, acp_id BIGINT, context_ou INT DEFAULT NULL) RETURNS NUMERIC AS $f$ +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; @@ -995,17 +1004,17 @@ BEGIN SELECT * INTO acn FROM asset.call_number WHERE id = acp.call_number; SELECT * INTO acl FROM asset.copy_location WHERE id = acp.location; - IF context_ou IS NULL THEN - context_ou := acp.circ_lib; + 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 = context_ou AND to_org = ahr.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(context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + 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) @@ -1030,7 +1039,7 @@ BEGIN FOR aoupa IN SELECT adj.* FROM actor.org_unit_proximity_adjustment adj - LEFT JOIN actor.org_unit_ancestors_distance(context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + 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) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom-best-hold-selection.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom-best-hold-selection.sql index bb1f6e7c26..55e390682f 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom-best-hold-selection.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom-best-hold-selection.sql @@ -6,11 +6,13 @@ CREATE TABLE config.best_hold_order( 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 + 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 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 index d9eb082a5b..43876d80cd 100644 --- 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 @@ -32,7 +32,16 @@ CREATE OR REPLACE FUNCTION actor.org_unit_ancestors_distance( INT ) RETURNS TABL 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, context_ou INT DEFAULT NULL) RETURNS NUMERIC AS $f$ +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; @@ -54,17 +63,17 @@ BEGIN SELECT * INTO acn FROM asset.call_number WHERE id = acp.call_number; SELECT * INTO acl FROM asset.copy_location WHERE id = acp.location; - IF context_ou IS NULL THEN - context_ou := acp.circ_lib; + 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 = context_ou AND to_org = ahr.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(context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + 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) @@ -89,7 +98,7 @@ BEGIN FOR aoupa IN SELECT adj.* FROM actor.org_unit_proximity_adjustment adj - LEFT JOIN actor.org_unit_ancestors_distance(context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib) + 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)