From: Mike Rylander Date: Tue, 23 Aug 2016 20:59:33 +0000 (-0400) Subject: LP#1464709: Disentangle hold bits from is_available X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmiker%2Flp1464709-copy-status-is-available;p=working%2FEvergreen.git LP#1464709: Disentangle hold bits from is_available We need to avoid conflating a status's available equivalence with its desirablity as a hold target. So, we will leave the "On holds shelf" status as special in circulation, and not touch the hold targeter or pull list code. That's the primary effect of this commit. Instead, a future revision will add something like the is_available flag, but defining the targetability of a status, and use that in the targetter. Further use of is_available may happen once is_targetable (or whatever it ends up being called) is created. Signed-off-by: Mike Rylander --- 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 f5e6cd68a8..3d592d66d1 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 @@ -760,9 +760,7 @@ sub hold_pull_list { my $count = 1 if ($self->api_name =~/count$/o); my $status_filter = ''; - $status_filter = - 'AND a.status IN ((SELECT id FROM config.copy_status WHERE is_available))' - if ($self->api_name =~/status_filtered/o); + $status_filter = 'AND a.status IN (0,7)' if ($self->api_name =~/status_filtered/o); my $select = <<" SQL"; SELECT h.* @@ -1096,9 +1094,6 @@ sub new_hold_copy_targeter { $self->{target_weight} = {}; $self->{max_loops} = {}; - my %avail_statuses = map { $_->id => 1 } - config::copy_status->search_where({is_available => 't'}); - my $holds; try { @@ -1432,12 +1427,11 @@ sub new_hold_copy_targeter { # reset prox list after trimming good copies $prox_list = create_prox_list( $self, $pu_lib, - [ grep { exists($avail_statuses{$_->status}) } @good_copies ], + [ grep { $_->status == 0 || $_->status == 7 } @good_copies ], $hold, $hold_copy_map ); - $all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && - exists($avail_statuses{$_->status}) } @good_copies ]; + $all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && ( $_->status == 0 || $_->status == 7 ) } @good_copies ]; my $min_prox = [ sort keys %$prox_list ]->[0]; my $best; @@ -1714,9 +1708,6 @@ sub reservation_targeter { my $reservations; - my %avail_statuses = map { $_->id => 1 } - config::copy_status->search_where({is_available => 't'}); - try { if ($one_reservation) { $self->method_lookup('open-ils.storage.transaction.begin')->run( $client ); @@ -1818,7 +1809,7 @@ sub reservation_targeter { next; } - if (exists($avail_statuses{$copy->status->id})) { + if ($copy->status->id == 0 || $copy->status->id == 7) { push @good_resources, $res; next; } diff --git a/Open-ILS/src/sql/Pg/100.circ_matrix.sql b/Open-ILS/src/sql/Pg/100.circ_matrix.sql index 9b33fa80a1..90991b6aac 100644 --- a/Open-ILS/src/sql/Pg/100.circ_matrix.sql +++ b/Open-ILS/src/sql/Pg/100.circ_matrix.sql @@ -497,7 +497,7 @@ BEGIN END IF; -- Fail if the item isn't in a circulateable status on a non-renewal - IF NOT renewal AND item_object.status NOT IN ( + IF NOT renewal AND item_object.status <> 8 AND item_object.status NOT IN ( (SELECT id FROM config.copy_status WHERE is_available) ) THEN result.fail_part := 'asset.copy.status'; result.success := FALSE; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index c1470a5a7a..86604414bd 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -313,7 +313,7 @@ INSERT INTO config.copy_status (id,name) VALUES (4,oils_i18n_gettext(4, 'Missing INSERT INTO config.copy_status (id,name,holdable,opac_visible) VALUES (5,oils_i18n_gettext(5, 'In process', 'ccs', 'name'),'t','t'); INSERT INTO config.copy_status (id,name,holdable,opac_visible,restrict_copy_delete) VALUES (6,oils_i18n_gettext(6, 'In transit', 'ccs', 'name'),'t','t','t'); INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,is_available) VALUES (7,oils_i18n_gettext(7, 'Reshelving', 'ccs', 'name'),'t','t','t','t'); -INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete,is_available) VALUES (8,oils_i18n_gettext(8, 'On holds shelf', 'ccs', 'name'),'t','t','t','t','t'); +INSERT INTO config.copy_status (id,name,holdable,opac_visible,copy_active,restrict_copy_delete) VALUES (8,oils_i18n_gettext(8, 'On holds shelf', 'ccs', 'name'),'t','t','t','t'); INSERT INTO config.copy_status (id,name,holdable,opac_visible) VALUES (9,oils_i18n_gettext(9, 'On order', 'ccs', 'name'),'t','t'); INSERT INTO config.copy_status (id,name,copy_active) VALUES (10,oils_i18n_gettext(10, 'ILL', 'ccs', 'name'),'t'); INSERT INTO config.copy_status (id,name) VALUES (11,oils_i18n_gettext(11, 'Cataloging', 'ccs', 'name')); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_status_co_allowed.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_status_co_allowed.sql index b787c1adad..c6ade184e1 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_status_co_allowed.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_status_co_allowed.sql @@ -4,7 +4,7 @@ ALTER TABLE config.copy_status ADD COLUMN is_available BOOL NOT NULL DEFAULT FALSE; UPDATE config.copy_status SET is_available = TRUE - WHERE id IN (0, 7, 8); -- available, reshelving, holds shelf. + WHERE id IN (0, 7); -- available, reshelving, holds shelf. CREATE OR REPLACE FUNCTION action.item_user_circ_test( circ_ou INT, match_item BIGINT, match_user INT, renewal BOOL ) RETURNS SETOF action.circ_matrix_test_result AS $func$ DECLARE @@ -92,7 +92,7 @@ BEGIN END IF; -- Fail if the item isn't in a circulateable status on a non-renewal - IF NOT renewal AND item_object.status NOT IN ( + IF NOT renewal AND item_object.status <> 8 AND item_object.status NOT IN ( (SELECT id FROM config.copy_status WHERE is_available) ) THEN result.fail_part := 'asset.copy.status'; result.success := FALSE;