From: Bill Erickson Date: Wed, 29 Jun 2016 21:22:00 +0000 (-0400) Subject: LP#1596595 Holdable formats filtering for metarecord holds X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=326a8e2c87ae5ca916f5dad555aa0b803975309a;p=working%2FEvergreen.git LP#1596595 Holdable formats filtering for metarecord holds Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm index d80c041aa1..e55e276e61 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm @@ -467,8 +467,6 @@ sub get_hold_copies { unless ($hold_type eq 'C' || $hold_type eq 'I' || $hold_type eq 'P') { # For volume and higher level holds, avoid targeting copies that # act as instances of monograph parts. - # TODO: Should this include 'R' holds? The original hold - # targeter does not include them either. $query->{from}->{acp}->{acpm} = { type => 'left', field => 'target_copy', @@ -535,6 +533,29 @@ sub get_hold_copies { } } }; + + if ($hold->holdable_formats) { + # Compile the JSON-encoded metarecord holdable formats + # to an Intarray query_int string. + my $query_int = $e->json_query({ + from => [ + 'metabib.compile_composite_attr', + $hold->holdable_formats + ] + })->[0]; + # TODO: ^- any way to add this as a filter in the main query? + + if ($query_int) { + # Only pull potential copies from records that satisfy + # the holdable formats query. + my $qint = $query_int->{'metabib.compile_composite_attr'}; + $query->{from}->{acp}->{acn}->{join}->{bre}->{join}->{mravl} = { + field => 'source', + fkey => 'id', + filter => {vlist => {'@@' => $qint}} + } + } + } } my $copies = $e->json_query($query);