From f7588ed11f14ba8e8b12d94de4ec3241f256ad40 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 27 Aug 2015 17:44:14 -0400 Subject: [PATCH] LP#1464709 Hold targeter / pull list uses is_available Holds targeter and pull list generator treat copies with an is_available=true status the same as "available" and "reshelving". Signed-off-by: Bill Erickson --- Open-ILS/examples/fm_IDL.xml | 3 ++- .../lib/OpenILS/Application/Storage/Publisher/action.pm | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 8011b9a8e6..d2ddcd6f23 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5616,6 +5616,7 @@ SELECT usr, ahcm_1.copy_count AS potential_copies FROM action.hold_request ahr JOIN asset.copy acp ON (acp.id = ahr.current_copy) + JOIN config.copy_status ccs ON (ccs.id = acp.status) JOIN asset.call_number acn ON (acp.call_number = acn.id) JOIN asset.call_number_prefix acnp ON (acn.prefix = acnp.id) JOIN asset.call_number_suffix acns ON (acn.suffix = acns.id) @@ -5651,7 +5652,7 @@ SELECT usr, ahr.cancel_time IS NULL AND csp.id IS NULL AND (ahr.expire_time is NULL OR ahr.expire_time > NOW()) AND - acp.status IN (0,7) + ccs.is_available ]]> 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 3d592d66d1..3bc6f4c3cb 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,7 +760,9 @@ sub hold_pull_list { my $count = 1 if ($self->api_name =~/count$/o); my $status_filter = ''; - $status_filter = 'AND a.status IN (0,7)' if ($self->api_name =~/status_filtered/o); + $status_filter = + 'AND a.status IN ((SELECT id FROM config.copy_status WHERE is_available))' + if ($self->api_name =~/status_filtered/o); my $select = <<" SQL"; SELECT h.* @@ -1094,6 +1096,9 @@ sub new_hold_copy_targeter { $self->{target_weight} = {}; $self->{max_loops} = {}; + my %avail_statuses = map { $_->id => 1 } + @{asset::copy_status->search_where({is_available => 't'})}; + my $holds; try { @@ -1427,11 +1432,12 @@ sub new_hold_copy_targeter { # reset prox list after trimming good copies $prox_list = create_prox_list( $self, $pu_lib, - [ grep { $_->status == 0 || $_->status == 7 } @good_copies ], + [ grep { exists($avail_statuses{$_->status}) } @good_copies ], $hold, $hold_copy_map ); - $all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && ( $_->status == 0 || $_->status == 7 ) } @good_copies ]; + $all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && + exists($avail_statuses{$_->status}) } @good_copies ]; my $min_prox = [ sort keys %$prox_list ]->[0]; my $best; @@ -1708,6 +1714,9 @@ sub reservation_targeter { my $reservations; + my %avail_statuses = map { $_->id => 1 } + @{asset::copy_status->search_where({is_available => 't'})}; + try { if ($one_reservation) { $self->method_lookup('open-ils.storage.transaction.begin')->run( $client ); @@ -1809,7 +1818,7 @@ sub reservation_targeter { next; } - if ($copy->status->id == 0 || $copy->status->id == 7) { + if (exists($avail_statuses{$copy->status->id})) { push @good_resources, $res; next; } -- 2.11.0