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> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
89e65657b1
commit
7343e404b7
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue