Bugzilla – Attachment 139293 Details for
Bug 31222
DBIC queries for batch mod can be very large
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31222: Reduce query size for batchMod
Bug-31222-Reduce-query-size-for-batchMod.patch (text/plain), 3.07 KB, created by
Jonathan Druart
on 2022-08-17 13:17:47 UTC
(
hide
)
Description:
Bug 31222: Reduce query size for batchMod
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-17 13:17:47 UTC
Size:
3.07 KB
patch
obsolete
>From 2ce90e803401de9af8d52c0ec187682332081e7a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 22 Jul 2022 14:47:36 +0000 >Subject: [PATCH] Bug 31222: Reduce query size for batchMod > >The object search is currently: >Koha::Items->search({ barcode => \@contentlist } > >Which generate code like: >barcode = 1 OR barcode = 2 OR barcode = 3 .... > >This can get quite large > >We can reduce the query size by using -in: >Koha::Items->search({ barcode => { -in => \@contentlist } } > >Which generates code like: >barcode in ( 1, 2, 3 ) > >To test: >1 - Apply patch >2 - Perform batch modifications >3 - Confirm nothing has changed > >Signed-off-by: Rachael Laritz <rachael.laritz@inlibro.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > tools/batchMod.pl | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index e24db19104a..a1e2bd476bc 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -218,13 +218,13 @@ if ($op eq "show"){ > @contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist ); > @contentlist = uniq @contentlist; > # Note: adding lc for case insensitivity >- my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@contentlist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; >+ my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => { -in => \@contentlist } }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; > @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @contentlist; > @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @contentlist; > } > elsif ( $filecontent eq 'itemid_file') { > @contentlist = uniq @contentlist; >- my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => \@contentlist }, { columns => [ 'itemnumber' ] } )->unblessed }; >+ my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => { -in => \@contentlist } }, { columns => [ 'itemnumber' ] } )->unblessed }; > @itemnumbers = grep { exists $itemdata{$_} } @contentlist; > @notfounditemnumbers = grep { !exists $itemdata{$_} } @contentlist; > } >@@ -240,7 +240,7 @@ if ($op eq "show"){ > @barcodelist = map { barcodedecode( $_ ) } @barcodelist; > > # Note: adding lc for case insensitivity >- my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; >+ my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => { -in => \@barcodelist } }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; > @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist; > @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @barcodelist; > } >-- >2.25.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 31222
:
138038
|
138737
| 139293