Bugzilla – Attachment 121150 Details for
Bug 28384
Add 'no_items' option to TransformMarcToKoha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28384: Add 'no_items' option to TransformMarcToKoha
Bug-28384-Add-noitems-option-to-TransformMarcToKoh.patch (text/plain), 4.71 KB, created by
David Nind
on 2021-05-19 11:02:51 UTC
(
hide
)
Description:
Bug 28384: Add 'no_items' option to TransformMarcToKoha
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-05-19 11:02:51 UTC
Size:
4.71 KB
patch
obsolete
>From b4350f3f8b61d287f42934db0ab8aacbf83c6d60 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 19 May 2021 10:19:33 +0000 >Subject: [PATCH] Bug 28384: Add 'no_items' option to TransformMarcToKoha > >This patch adds a new option 'no_items' and uses it in the C4::Search::searchResults >routine. We don't use the item info fetched here, so skipping those lines saves us time. > >Additionally, I fix an incorrect FIXME comment, and pass the ISBN returned by the routine above >into GetNormalizedISBN to save another lookup > >TO test: >1 - Enable AmazonCoverImages system preference >2 - Search staff client with a term that returns books with covers >3 - Apply patch >4 - prove -v t/db_dependent/Biblio/TransformMarcToKoha.t >5 - Confirm searching works >6 - Confirm Amazon images display (normalized_isbn is used for these) > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Biblio.pm | 2 ++ > C4/Search.pm | 8 ++++---- > t/db_dependent/Biblio/TransformMarcToKoha.t | 11 ++++++++++- > 3 files changed, 16 insertions(+), 5 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index df72e511be..04771e26c3 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2343,6 +2343,8 @@ sub TransformMarcToKoha { > my %tables = ( biblio => 1, biblioitems => 1, items => 1 ); > if( $limit_table eq 'items' ) { > %tables = ( items => 1 ); >+ } elsif ( $limit_table eq 'no_items' ){ >+ %tables = ( biblio => 1, biblioitems => 1 ); > } > > # The next call acknowledges Default as the authoritative framework >diff --git a/C4/Search.pm b/C4/Search.pm >index 0db460a808..10c804f0c2 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1648,12 +1648,12 @@ sub searchResults { > } > > # handle which records to actually retrieve >- my $times; >+ my $times; # Times is which record to process up to > if ( $hits && $offset + $results_per_page <= $hits ) { > $times = $offset + $results_per_page; > } > else { >- $times = $hits; # FIXME: if $hits is undefined, why do we want to equal it? >+ $times = $hits; # If less hits than results_per_page+offset we go to the end > } > > my $marcflavour = C4::Context->preference("marcflavour"); >@@ -1707,13 +1707,13 @@ sub searchResults { > : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf)); > > SetUTF8Flag($marcrecord); >- my $oldbiblio = TransformMarcToKoha( $marcrecord, $fw ); >+ my $oldbiblio = TransformMarcToKoha( $marcrecord, $fw, 'no_items' ); > $oldbiblio->{result_number} = $i + 1; > > $oldbiblio->{normalized_upc} = GetNormalizedUPC( $marcrecord,$marcflavour); > $oldbiblio->{normalized_ean} = GetNormalizedEAN( $marcrecord,$marcflavour); > $oldbiblio->{normalized_oclc} = GetNormalizedOCLCNumber($marcrecord,$marcflavour); >- $oldbiblio->{normalized_isbn} = GetNormalizedISBN(undef,$marcrecord,$marcflavour); >+ $oldbiblio->{normalized_isbn} = GetNormalizedISBN($oldbiblio->{isbn},$marcrecord,$marcflavour); # Use existing ISBN from record if we got one > $oldbiblio->{content_identifier_exists} = 1 if ($oldbiblio->{normalized_isbn} or $oldbiblio->{normalized_oclc} or $oldbiblio->{normalized_ean} or $oldbiblio->{normalized_upc}); > > # edition information, if any >diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t >index 60d7a95833..1a08ded4f0 100755 >--- a/t/db_dependent/Biblio/TransformMarcToKoha.t >+++ b/t/db_dependent/Biblio/TransformMarcToKoha.t >@@ -111,7 +111,7 @@ subtest 'Testing _adjust_pubyear' => sub { > }; > > subtest 'Test repeatable subfields' => sub { >- plan tests => 2; >+ plan tests => 5; > > # Make 510x repeatable and 510y not > Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete; >@@ -125,6 +125,15 @@ subtest 'Test repeatable subfields' => sub { > my $result = C4::Biblio::TransformMarcToKoha( $marc ); > is( $result->{test}, '1 | 2', 'Check 510x for two values' ); > is( $result->{norepeat}, '3 | 4 | 5', 'Check 510y too' ); >+ >+ Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; >+ Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); >+ $marc->append_fields( MARC::Field->new( '510', '', '', a => '1' ) ); # actually, we should only have one $y (BZ 24652) >+ >+ $result = C4::Biblio::TransformMarcToKoha( $marc, '', 'no_items' ); >+ is( $result->{test}, undef, 'Item field not returned when "no_items" passed' ); >+ is( $result->{norepeat}, undef, 'Item field not returned when "no_items" passed' ); >+ is( $result->{field1}, 1, 'Biblio field returned when "no_items" passed' ); > }; > > # Cleanup >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28384
:
121146
|
121150
|
122418
|
122419
|
122420