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',
}
}
};
+
+ 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);