Bugzilla – Attachment 76490 Details for
Bug 21006
GetMarcBiblio is slow for records with many items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21006: Add GetMarcItems method and refactor GetMarcBiblio
Bug-21006-Add-GetMarcItems-method-and-refactor-Get.patch (text/plain), 3.04 KB, created by
Nick Clemens (kidclamp)
on 2018-06-27 13:15:40 UTC
(
hide
)
Description:
Bug 21006: Add GetMarcItems method and refactor GetMarcBiblio
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-06-27 13:15:40 UTC
Size:
3.04 KB
patch
obsolete
>From 9551c0a2a449547831cd3b4ad9acafe8d283a7a0 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 27 Jun 2018 02:58:55 +0000 >Subject: [PATCH] Bug 21006: Add GetMarcItems method and refactor GetMarcBiblio > >--- > C4/Biblio.pm | 9 +++------ > C4/Items.pm | 32 ++++++++++++++++++++++++++++++-- > 2 files changed, 33 insertions(+), 8 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 0c5a917..8e55254 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1194,6 +1194,7 @@ sub GetMarcBiblio { > > C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, > $biblioitemnumber ); >+ > C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, $opac ) > if ($embeditems); > >@@ -2816,12 +2817,8 @@ sub EmbedItemsInMarcBiblio { > : (); > # Convert to a hash for quick searching > my %hiddenitems = map { $_ => 1 } @hiddenitems; >- foreach my $itemnumber ( map { $_->{itemnumber} } @items ) { >- next if $hiddenitems{$itemnumber}; >- my $item_marc = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); >- push @item_fields, $item_marc->field($itemtag); >- } >- $marc->append_fields(@item_fields); >+ my $item_fields = C4::Items::GetMarcItems( $biblionumber, \@hiddenitems, $itemtag ); >+ $marc->append_fields(@$item_fields); > } > > =head1 INTERNAL FUNCTIONS >diff --git a/C4/Items.pm b/C4/Items.pm >index bf464c3..660bba1 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1496,14 +1496,42 @@ sub GetMarcItem { > return Item2Marc($itemrecord,$biblionumber); > > } >+ >+=head2 GetMarcItems >+ >+ my @items_marc = GetMarcItems($biblionumber, \@hiddenitemnumbers); >+ >+Returns array of MARC::Records of the items for the biblio passed in parameter. >+ >+=cut >+ >+sub GetMarcItems { >+ my ( $biblionumber, $hiddenitems, $itemtag ) = @_; >+ my $params; >+ $params->{biblionumber} = $biblionumber; >+ $params->{itemnumber} = {'not in' => @$hiddenitems} if defined $hiddenitems && scalar @$hiddenitems; >+ my $items = Koha::Items->search($params ); >+ return unless $items; >+ >+ # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. >+ # Also, don't emit a subfield if the underlying field is blank. >+ >+ my $framework = Koha::Biblios->find( $biblionumber)->frameworkcode(); >+ my @marc_items; >+ while ( my $this_item = $items->next() ){ >+ push @marc_items, Item2Marc($this_item->unblessed,$biblionumber,$framework)->field($itemtag); >+ } >+ return \@marc_items; >+} >+ > sub Item2Marc { >- my ($itemrecord,$biblionumber)=@_; >+ my ($itemrecord,$biblionumber, $frameworkcode)=@_; > my $mungeditem = { > map { > defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () > } keys %{ $itemrecord } > }; >- my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); >+ my $framework = $frameworkcode // C4::Biblio::GetFrameworkCode( $biblionumber ); > my $itemmarc = C4::Biblio::TransformKohaToMarc( > $mungeditem, { no_split => 1}, > ); >-- >2.1.4
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 21006
:
76475
|
76490
|
76659
|
76660
|
76661