Bugzilla – Attachment 138008 Details for
Bug 31216
inventory.pl is slow when comparing many barcodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31216: Make one call to fetch AVs before substituting
Bug-31216-Make-one-call-to-fetch-AVs-before-substi.patch (text/plain), 2.82 KB, created by
Nick Clemens (kidclamp)
on 2022-07-22 11:10:48 UTC
(
hide
)
Description:
Bug 31216: Make one call to fetch AVs before substituting
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-07-22 11:10:48 UTC
Size:
2.82 KB
patch
obsolete
>From 56d533a90d95885ff5061bf872fa645c0d9c0983 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 22 Jul 2022 11:07:52 +0000 >Subject: [PATCH] Bug 31216: Make one call to fetch AVs before substituting > >This patch copies logic from GetItemsForInventory as it proves >much faster at updating values > >Probably this should be a subroutine? BUt we have cachign patches in the >works too (bug 30920) > >Additionally - it looks like current inventory code looks for framework from items, but I am >not sure we fetch it anywhere >--- > tools/inventory.pl | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > >diff --git a/tools/inventory.pl b/tools/inventory.pl >index 6fe7e79014..849a3e6ea6 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -296,6 +296,18 @@ if( @scanned_items ) { > > } > >+ my @avs = Koha::AuthorisedValues->search( >+ { 'marc_subfield_structures.kohafield' => { '>' => '' }, >+ 'me.authorised_value' => { '>' => '' }, >+ }, >+ { join => { category => 'marc_subfield_structures' }, >+ distinct => ['marc_subfield_structures.kohafield, me.category, frameworkcode, me.authorised_value'], >+ '+select' => [ 'marc_subfield_structures.kohafield', 'marc_subfield_structures.frameworkcode', 'me.authorised_value', 'me.lib' ], >+ '+as' => [ 'kohafield', 'frameworkcode', 'authorised_value', 'lib' ], >+ } >+ )->as_list; >+ my $avmapping = { map { $_->get_column('kohafield') . ',' . $_->get_column('frameworkcode') . ',' . $_->get_column('authorised_value') => $_->get_column('lib') } @avs }; >+ > # Report scanned items that are on the wrong place, or have a wrong notforloan > # status, or are still checked out. > for ( my $i = 0; $i < @scanned_items; $i++ ) { >@@ -306,14 +318,17 @@ for ( my $i = 0; $i < @scanned_items; $i++ ) { > my $fc = $item->{'frameworkcode'} || ''; > > # Populating with authorised values description >- foreach my $field (qw/ location notforloan itemlost damaged withdrawn /) { >- my $av = Koha::AuthorisedValues->get_description_by_koha_field( >- { frameworkcode => $fc, kohafield => "items.$field", authorised_value => $item->{$field} } ); >- if ( $av and defined $item->{$field} and defined $av->{lib} ) { >- $item->{$field} = $av->{lib}; >+ foreach (keys %$item) { >+ if ( >+ defined( >+ $avmapping->{ "items.$_," . $fc . "," . ( $item->{$_} // q{} ) } >+ ) >+ ) { >+ $item->{$_} = $avmapping->{"items.$_,".$fc.",".$item->{$_}}; > } > } > >+ > # If we have scanned items with a non-matching notforloan value > if( none { $item->{'notforloancode'} eq $_ } @notforloans ) { > $item->{problems}->{changestatus} = 1; >-- >2.30.2
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 31216
: 138008