$unapi_args->{depth} ||= $self->ctx->{aou_tree}->()->ou_type->depth;
$unapi_args->{flesh_depth} ||= 5;
+ my $is_meta = delete $unapi_args->{metarecord};
+ my $unapi_type = $is_meta ? 'unapi.mmr' : 'unapi.bre';
+
$unapi_cache ||= OpenSRF::Utils::Cache->new('global');
my $unapi_cache_key_suffix = join(
'_',
+ $is_meta || 0,
$unapi_args->{site},
$unapi_args->{depth},
$unapi_args->{flesh_depth},
$outer_self->timelog("get_records_and_facets(): got response content");
# Protect against requests for non-existent records
- return unless $data->{'unapi.bre'};
+ return unless $data->{$unapi_type};
+
+ my $xml = XML::LibXML->new->parse_string($data->{$unapi_type})->documentElement;
- my $xml = XML::LibXML->new->parse_string($data->{'unapi.bre'})->documentElement;
+ # NOTE: in metarecord mode, the bre_id will be that of the master
+ # record, in which case the bre_id acts as a secondary identifier
+ # for the metarecord. Caching via $bre_id (w/ is_meta key_suffix
+ # adjustments from above) should still produce unique cache
+ # values for each MR. IOW, there' no particular need to extract
+ # the MR id.
$outer_self->timelog("get_records_and_facets(): parsed xml");
# Protect against legacy invalid MARCXML that might not have a 901c
my $key = 'TPAC_unapi_cache_'.$bre_id.'_'.$unapi_cache_key_suffix;
my $cache_data = $unapi_cache->get_cache($key);
if ($$cache_data{running}) {
- $unapi_cache->put_cache($key, { id => $bre_id, marc_xml => $data->{'unapi.bre'} }, 10);
+ $unapi_cache->put_cache($key, { id => $bre_id, marc_xml => $data->{$unapi_type} }, 10);
}
}
}
);
- $self->timelog("get_records_and_facets(): about to call unapi.bre via json_query (rec_ids has " . scalar(@$rec_ids));
+ $self->timelog("get_records_and_facets(): about to call ".
+ "$unapi_type via json_query (rec_ids has " . scalar(@$rec_ids));
my @loop_recs = @$rec_ids;
my %rec_timeout;
$tmp_data{$unapi_data->{id}} = $unapi_data;
} else { # we're the first or we timed out. success_handler will populate the real value
$unapi_cache->put_cache($unapi_cache_key, { running => $$ }, 10);
+
+ my $sdepth = $unapi_args->{flesh_depth};
+ my $slimit = "acn=>$sdepth,acp=>$sdepth";
+ $slimit .= ",bre=>$sdepth" if $is_meta;
+
$ses->request(
'open-ils.cstore.json_query',
{from => [
- 'unapi.bre', $bid, 'marcxml','record',
+ $unapi_type, $bid, 'marcxml','record',
$unapi_args->{flesh},
$unapi_args->{site},
$unapi_args->{depth},
- 'acn=>' . $unapi_args->{flesh_depth} . ',acp=>' . $unapi_args->{flesh_depth},
+ $slimit,
undef, undef, $unapi_args->{pref_lib}
]}
);
}
-
}