Bugzilla – Attachment 175411 Details for
Bug 38691
FRBRizeEditions should look directly in the local catalog for other editions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38691 - WIP - FRBRizeEditions should look directly in the local catalog for other editions
0001-Bug-38691-WIP-FRBRizeEditions-should-look-directly-i.patch (text/plain), 3.71 KB, created by
Olli-Antti Kivilahti
on 2024-12-12 16:14:44 UTC
(
hide
)
Description:
Bug 38691 - WIP - FRBRizeEditions should look directly in the local catalog for other editions
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2024-12-12 16:14:44 UTC
Size:
3.71 KB
patch
obsolete
>From 608a9cee92f7dbb19670d058d2f74b3f7fd44841 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@hypernova.fi> >Date: Thu, 12 Dec 2024 18:10:39 +0200 >Subject: [PATCH] Bug 38691 - WIP - FRBRizeEditions should look directly in the > local catalog for other editions > >Currently FRBRizeEditions only looks from a remote service for other editions for a given ISBN. >Local queries are only done to validate that the local database has the results found from the external source. >Instead/on-the-side we should do a local lookup for other editions of the same biblio. > >WIP >This is a result of a quick test to make the FRBRizeEditions-feature do something and have a >PoC of what it actually does. Hopefully this will help somebody someday. >--- > lib/C4/XISBN.pm | 41 ++++++++++++++++++++++------------------- > 1 file changed, 22 insertions(+), 19 deletions(-) > >diff --git a/lib/C4/XISBN.pm b/lib/C4/XISBN.pm >index 67d89ea..321fe47 100644 >--- a/lib/C4/XISBN.pm >+++ b/lib/C4/XISBN.pm >@@ -50,27 +50,31 @@ This module provides facilities for retrieving ThingISBN and XISBN content in Ko > > =cut > >-sub _get_biblio_from_xisbn { >+sub _get_biblios_from_xisbn { > my $xisbn = shift; > my $dbh = C4::Context->dbh; > > my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); >- my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 ); >+ my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 50 ); > return unless ( !$errors && scalar @$results ); > >- my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] ); >- my $biblionumber = C4::Biblio::TransformMarcToKoha({ >- kohafields => ['biblio.biblionumber'], >- record => $record >- })->{biblionumber}; >- return unless $biblionumber; >- >- my $biblio = Koha::Biblios->find( $biblionumber ); >- return unless $biblio; >- my $isbn = $biblio->biblioitem->isbn; >- $biblio = $biblio->unblessed; >- $biblio->{normalized_isbn} = GetNormalizedISBN($isbn); >- return $biblio; >+ my @biblios; >+ for my $result (@$results) { >+ my $record = C4::Search::new_record_from_zebra( 'biblioserver', $result ); >+ my $biblionumber = C4::Biblio::TransformMarcToKoha({ >+ kohafields => ['biblio.biblionumber'], >+ record => $record >+ })->{biblionumber}; >+ next unless $biblionumber; >+ >+ my $biblio = Koha::Biblios->find( $biblionumber ); >+ next unless $biblio; >+ my $isbn = $biblio->biblioitem->isbn; >+ $biblio = $biblio->unblessed; >+ $biblio->{normalized_isbn} = GetNormalizedISBN($isbn); >+ push(@biblios, $biblio); >+ } >+ return \@biblios; > } > > =head1 get_xisbns($isbn, $biblionumber); >@@ -97,7 +101,7 @@ sub get_xisbns { > $syndetics_response = {isbn => \@syndetics_response}; > } > >- $response->{isbn} = [ @{ $syndetics_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] } ]; >+ $response->{isbn} = [{content => $isbn}, @{ $syndetics_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] } ]; > my @xisbns; > my $unique_xisbns; # a hashref > >@@ -105,9 +109,8 @@ sub get_xisbns { > for my $response_data( @{ $response->{ isbn } } ) { > next if $unique_xisbns->{ $response_data->{content} }; > $unique_xisbns->{ $response_data->{content} }++; >- my $xbiblio= _get_biblio_from_xisbn($response_data->{content}); >- next unless $xbiblio; >- push @xisbns, $xbiblio if $xbiblio && $xbiblio->{biblionumber} ne $biblionumber; >+ my $xbiblios= _get_biblios_from_xisbn($response_data->{content}); >+ push @xisbns, grep {$_->{biblionumber} ne $biblionumber} @$xbiblios; > } > if ( wantarray ) { > return (\@xisbns, $errors); >-- >2.34.1 >
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 38691
: 175411