From ada5fb591dbd46234678c875bb49db031815575e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 20 Jan 2014 15:06:58 -0500 Subject: [PATCH] LP#1053397 remove deprecated AC key lookup Remove the extra, unnecessary DB call to find the record's added content key, since the lookups are now based on the record ID instead of the ISBN, etc. Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 49 +++------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index d633c6f893..2a68c0e92a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -496,8 +496,6 @@ sub added_content_stage1 { my $rec_id = shift; my $ctx = $self->ctx; my $sel_type = $self->cgi->param('ac') || ''; - my $key = $self->get_ac_key($rec_id); - ($key = $key->{value}) =~ s/^\s+//g if $key; # Connect to this machine's IP address, using the same # Host with which our caller used to connect to us. @@ -513,10 +511,10 @@ sub added_content_stage1 { for my $type (@$ac_types) { last if $ac_failed; $ctx->{added_content}->{$type} = {content => ''}; - $ctx->{added_content}->{$type}->{status} = $key ? 3 : 2; + $ctx->{added_content}->{$type}->{status} = $rec_id ? 3 : 2; - if ($key) { - $logger->debug("tpac: starting added content request for $key => $type"); + if ($rec_id) { + $logger->debug("tpac: starting added content request for $rec_id => $type"); # Net::HTTP::NB is non-blocking /after/ the initial connect() # Passing Timeout=>1 ensures we wait no longer than 1 second to @@ -527,7 +525,7 @@ sub added_content_stage1 { my $req = Net::HTTP::NB->new(Host => $ac_addr, Timeout => 1); if (!$req) { $logger->warn("Unable to connect to $ac_addr / $ac_host". - " for added content lookup for $key: $@"); + " for added content lookup for $rec_id: $@"); $ac_failed = 1; next; } @@ -535,7 +533,8 @@ sub added_content_stage1 { $req->host($self->apache->hostname); my $http_type = ($type eq $sel_type) ? 'GET' : 'HEAD'; - $req->write_request($http_type => "/opac/extras/ac/$type/html/" . uri_escape_utf8($key)); + $req->write_request($http_type => + "/opac/extras/ac/$type/html/r/$rec_id"); $ctx->{added_content}->{$type}->{request} = $req; } } @@ -582,42 +581,6 @@ sub added_content_stage2 { } } -# XXX this is copied directly from AddedContent.pm in -# working/user/jeff/ac_by_record_id_rebase. When Jeff's -# branch is merged and Evergreen gets added content -# lookup by ID, this can be removed. -# returns [{tag => $tag, value => $value}, {tag => $tag2, value => $value2}] -sub get_ac_key { - my $self = shift; - my $rec_id = shift; - my $key_data = $self->editor->json_query({ - select => {mfr => ['tag', 'value']}, - from => 'mfr', - where => { - record => $rec_id, - '-or' => [ - { - '-and' => [ - {tag => '020'}, - {subfield => 'a'} - ] - }, { - '-and' => [ - {tag => '024'}, - {subfield => 'a'}, - {ind1 => 1} - ] - } - ] - } - }); - - return ( - grep {$_->{tag} eq '020'} @$key_data, - grep {$_->{tag} eq '024'} @$key_data - )[0]; -} - sub load_metarecord { my $self = shift; my %kwargs = @_; -- 2.11.0