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> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> [EDIT] Amended, replacing a tab character. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
a6d0ba552e
commit
5da5a2bbc5
|
|
@ -2347,6 +2347,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
|
||||
|
|
|
|||
|
|
@ -1637,12 +1637,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");
|
||||
|
|
@ -1696,13 +1696,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue