Bugzilla – Attachment 96242 Details for
Bug 23800
Batch modification tool orders items by barcode incremental by default (regression to 17.11)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23800: (QA follow-up) Fix item case, reduce code
Bug-23800-QA-follow-up-Fix-item-case-reduce-code.patch (text/plain), 4.45 KB, created by
Marcel de Rooy
on 2019-12-13 09:53:46 UTC
(
hide
)
Description:
Bug 23800: (QA follow-up) Fix item case, reduce code
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-12-13 09:53:46 UTC
Size:
4.45 KB
patch
obsolete
>From 711d9f35464fb89d0f7420fafd480a6f1f3ae670 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 13 Dec 2019 09:28:28 +0000 >Subject: [PATCH] Bug 23800: (QA follow-up) Fix item case, reduce code >Content-Type: text/plain; charset=utf-8 > >The solution for items does not work, since it compares barcodes. >Instead of a grep in a map, we could do simpler. > >Test plan: >Try barcode file, order not by itemnumber. Toggle with case. Add wrong code. >Try same via barcode list text area. >Try an itemnumber file, reorder again. Add wrong number. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > tools/batchMod.pl | 43 ++++++++++++------------------------------- > 1 file changed, 12 insertions(+), 31 deletions(-) > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 6f67d63d40..124d6f0b6a 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -262,28 +262,17 @@ if ($op eq "show"){ > if ($filecontent eq 'barcode_file') { > @contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist ); > @contentlist = uniq @contentlist; >- my @existing_items = @{ Koha::Items->search({ barcode => \@contentlist })->unblessed }; >- @existing_items = map { >- my $barcode = $_; >- grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items >- } @contentlist; >- @itemnumbers = map { $_->{itemnumber} } @existing_items; >- my @barcodes = map { $_->{barcode} } @existing_items; >- # to avoid problems with case sensitivity >- my %exists = map { lc($_) => 1 } @barcodes; >- @contentlist = map { lc($_) } @contentlist; >- @notfoundbarcodes = grep { !$exists{$_} } @contentlist; >+ # Note: adding lc for case insensitivity >+ my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@contentlist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; >+ my @barcodes = grep { exists $itemdata{lc $_} } @contentlist; >+ @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @contentlist; >+ @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @contentlist; > } > elsif ( $filecontent eq 'itemid_file') { > @contentlist = uniq @contentlist; >- my @existing_items = @{ Koha::Items->search({ itemnumber => \@contentlist })->unblessed }; >- @existing_items = map { >- my $barcode = $_; >- grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items >- } @contentlist; >- @itemnumbers = map { $_->{itemnumber} } @existing_items; >- my %exists = map { $_ => 1 } @itemnumbers; >- @notfounditemnumbers = grep { !$exists{$_} } @contentlist; >+ my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => \@contentlist }, { columns => [ 'itemnumber' ] } )->unblessed }; >+ @itemnumbers = grep { exists $itemdata{$_} } @contentlist; >+ @notfounditemnumbers = grep { !exists $itemdata{$_} } @contentlist; > } > } else { > if (defined $biblionumber){ >@@ -295,18 +284,10 @@ if ($op eq "show"){ > if ( my $list = $input->param('barcodelist') ) { > my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list ); > @barcodelist = uniq @barcodelist; >- >- my @existing_items = @{ Koha::Items->search({ barcode => \@barcodelist })->unblessed }; >- @existing_items = map { >- my $barcode = $_; >- grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items >- } @barcodelist; >- @itemnumbers = map { $_->{itemnumber} } @existing_items; >- my @barcodes = map { $_->{barcode} } @existing_items; >- # to avoid problems with case sensitivity >- my %exists = map { lc($_) => 1 } @barcodes; >- @barcodelist = map { lc($_) } @barcodelist; >- @notfoundbarcodes = grep { !$exists{$_} } @barcodelist; >+ # Note: adding lc for case insensitivity >+ my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; >+ @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist; >+ @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @barcodelist; > } > } > >-- >2.11.0
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 23800
:
93987
|
94032
|
94033
|
94034
|
94353
|
94354
|
95252
|
95659
|
96241
| 96242 |
96243