}
__PACKAGE__->register_method(
method => 'fetch_display_fields',
- api_name => 'open-ils.search.fetch.metabib.display_field.highlight'
+ api_name => 'open-ils.search.fetch.metabib.display_field.highlight',
+ stream => 1
);
$ctx->{fetch_display_fields} = sub {
my $id = shift;
- return $U->simplereq(
+
+ if (@$id == 1) {
+ return $ctx->{_hl_data}{''.$$id[0]}
+ if ($ctx->{_hl_data}{''.$$id[0]});
+ }
+
+ $self->timelog("HL data not cached, fetching from server.");
+
+ my $rows = $U->simplereq(
'open-ils.search',
'open-ils.search.fetch.metabib.display_field.highlight',
$ctx->{query_struct}{additional_data}{highlight_map},
map {int($_)} @$id
);
+
+ $ctx->{_hl_data}{''.$$id[0]} = $rows if (@$id == 1);
+
+ return $rows;
};
return Apache2::Const::OK;
);
my %tmp_data;
+ my %hl_tmp_data;
my $outer_self = $self;
my $sdepth = $unapi_args->{flesh_depth};
$flesh =~ s/}$/,mmr.unapi}/g if $is_meta;
my $ses = OpenSRF::AppSession->create('open-ils.cstore');
+ my $hl_ses = OpenSRF::AppSession->create('open-ils.search');
my @loop_recs;
for my $bid (@$rec_ids) {
]}
);
+ my $hl_req = $hl_ses->request(
+ 'open-ils.search.fetch.metabib.display_field.highlight.atomic',
+ $self->ctx->{query_struct}{additional_data}{highlight_map},
+ @$rec_ids
+ ) if (!$is_meta);
+
+
my $facets = {};
if ($facet_req) {
$self->timelog("get_records_and_facets():almost ready to fetch facets");
my $data = $unapi_req->gather(1);
- $outer_self->timelog("get_records_and_facets(): got response content");
+ $outer_self->timelog("get_records_and_facets(): got feed content");
+
+ if (!$is_meta) {
+ my $hl_data = $hl_req->gather(1); # list of arrayref of hashrefs
+ $self->ctx->{_hl_data} = { map { ''.$$_[0]{source} => $_ } @$hl_data };
+ $outer_self->timelog("get_records_and_facets(): got highlighting content (". keys(%{$self->ctx->{_hl_data}}).")");
+ }
# Protect against requests for non-existent records
return unless $data->{$unapi_type};
args.hl = {};
IF !CGI.param('no_highlight') && !search.no_highlight;
- junk = ctx.timelog('Fetching of highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', '));
args.display_field_list = ctx.fetch_display_fields(args.df_bib_list.list);
- junk = ctx.timelog('Finished fetch of highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', '));
junk = ctx.timelog('Mapping highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', '));
FOR df IN args.display_field_list;