</actions>
</permacrud>
</class>
+ <class id="cbho" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::best_hold_order" oils_persist:tablename="config.best_hold_order" reporter:label="Best-Hold Sort Order">
+ <fields oils_persist:primary="id" oils_persist:sequence="config.best_hold_order_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id" />
+ <field reporter:label="Name" name="name" reporter:datatype="text"/>
+ <field reporter:label="Capture Lib to Pickup Lib Proximity" name="pprox" reporter:datatype="int" />
+ <field reporter:label="Circ Lib to Request Lib Proximity" name="hprox" reporter:datatype="int" />
+ <field reporter:label="Adjusted Circ Lib to Pickup Lib Proximity" name="aprox" reporter:datatype="int" />
+ <field reporter:label="Adjusted Capture Location to Pickup Lib Proximity" name="approx" reporter:datatype="int" />
+ <field reporter:label="Hold Priority" name="priority" reporter:datatype="int" />
+ <field reporter:label="Hold Cut-in-line State" name="cut" reporter:datatype="int" />
+ <field reporter:label="Hold Selection Depth" name="depth" reporter:datatype="int" />
+ <field reporter:label="Copy Has Circulated From Home Lately" name="htime" reporter:datatype="int" />
+ <field reporter:label="Hold Request Time" name="rtime" reporter:datatype="int" />
+ <field reporter:label="Copy Has Been Home At All Lately" name="shtime" reporter:datatype="int" />
+ </fields>
+ <links>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_CONFIG_BEST_HOLD_ORDER" global_required="true"/>
+ <retrieve permission="ADMIN_CONFIG_BEST_HOLD_ORDER" global_required="true"/>
+ <update permission="ADMIN_CONFIG_BEST_HOLD_ORDER" global_required="true"/>
+ <delete permission="ADMIN_CONFIG_BEST_HOLD_ORDER" global_required="true"/>
+ </actions>
+ </permacrud>
+ </class>
<class id="cbfp" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::biblio_fingerprint" oils_persist:tablename="config.biblio_fingerprint" reporter:label="Fingerprint Definition">
<fields oils_persist:primary="id" oils_persist:sequence="config.biblio_fingerprint_id_seq">
<field name="id" reporter:datatype="id" />
# 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',
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(
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
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;
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)
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)
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
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;
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)
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)