Bugzilla – Attachment 113521 Details for
Bug 26963
Improve Koha::Item::pickup_locations performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26963: (QA follow-up) Fix up tests and cover case of undefined ccode
Bug-26963-QA-follow-up-Fix-up-tests-and-cover-case.patch (text/plain), 5.08 KB, created by
Martin Renvoize (ashimema)
on 2020-11-11 16:08:14 UTC
(
hide
)
Description:
Bug 26963: (QA follow-up) Fix up tests and cover case of undefined ccode
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-11-11 16:08:14 UTC
Size:
5.08 KB
patch
obsolete
>From 9caff6150c00eb361bed13214ba6b2f8120f1429 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 11 Nov 2020 13:26:58 +0000 >Subject: [PATCH] Bug 26963: (QA follow-up) Fix up tests and cover case of > undefined ccode > >While this technically shouldn't happen, if a library creates itemtype limits, then flips the pref, those rules are still in the db until a ccode rule is saved. > >To be extra safe, when checking for rules of one type, we should make sure the other type is undef - i.e. if looking for ccode rules, we should confirm the itype is undef for those rules > >Additionally, we shouldn't set the barcode now that we are not deleting all items, so we use copynumber for our item identification field as it doesn't need to be unique in the DB > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 10 ++++++++-- > t/db_dependent/Koha/Item.t | 24 ++++++++++++++++++------ > 2 files changed, 26 insertions(+), 8 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index ee483ef3e0..ad1e9a70ed 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -599,11 +599,17 @@ sub pickup_locations { > ) unless C4::Context->preference('UseBranchTransferLimits'); > > my $limittype = C4::Context->preference('BranchTransferLimitsType'); >- my $limiter = $limittype eq 'itemtype' ? $self->effective_itemtype : $self->ccode; >+ my ($ccode, $itype) = (undef, undef); >+ if( $limittype eq 'ccode' ){ >+ $ccode = $self->ccode; >+ } else { >+ $itype = $self->itype; >+ } > my $limits = Koha::Item::Transfer::Limits->search( > { > fromBranch => $self->holdingbranch, >- $limittype => $limiter >+ ccode => $ccode, >+ itemtype => $itype, > }, > { columns => ['toBranch'] } > ); >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 401254404d..b983cad934 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -178,7 +178,7 @@ subtest 'pickup_locations' => sub { > { > homebranch => $library1->branchcode, > holdingbranch => $library2->branchcode, >- barcode => '1', >+ copynumber => 1, > ccode => 'Gollum' > } > )->store; >@@ -187,7 +187,7 @@ subtest 'pickup_locations' => sub { > { > homebranch => $library3->branchcode, > holdingbranch => $library4->branchcode, >- barcode => '3', >+ copynumber => 3, > itype => $item1->itype, > } > )->store; >@@ -208,7 +208,7 @@ subtest 'pickup_locations' => sub { > my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } ); > > my $all_count = Koha::Libraries->search({ pickup_location => 1})->count(); >- plan tests => ($all_count +1) * 7 + 31 + 60; >+ plan tests => ($all_count +1) * 7 + 31 + 61; > > my $results = { > "1-1-1-any" => $all_count, >@@ -295,13 +295,13 @@ subtest 'pickup_locations' => sub { > } > ok( > scalar(@pl) == $results->{ >- $item->barcode . '-' >+ $item->copynumber . '-' > . $patron->firstname . '-' > . $ha . '-' > . $hfp > }, > 'item' >- . $item->barcode >+ . $item->copynumber > . ', patron' > . $patron->firstname > . ', holdallowed: ' >@@ -310,7 +310,7 @@ subtest 'pickup_locations' => sub { > . $hfp > . ' should return ' > . $results->{ >- $item->barcode . '-' >+ $item->copynumber . '-' > . $patron->firstname . '-' > . $ha . '-' > . $hfp >@@ -334,6 +334,15 @@ subtest 'pickup_locations' => sub { > } > > # Now test that branchtransferlimits will further filter the pickup locations >+ >+ my $item_no_ccode = $builder->build_sample_item( >+ { >+ homebranch => $library1->branchcode, >+ holdingbranch => $library2->branchcode, >+ itype => $item1->itype, >+ } >+ )->store; >+ > t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); > t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype'); > Koha::CirculationRules->set_rules( >@@ -381,6 +390,9 @@ subtest 'pickup_locations' => sub { > $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; > is( scalar @$pickup_locations, $all_count, "With no transfer limits of type ccode we get back the libraries that are pickup locations"); > >+ $pickup_locations = $item_no_ccode->pickup_locations( { patron => $patron1 } )->as_list; >+ is( scalar @$pickup_locations, $all_count, "With no transfer limits of type ccode and an item with no ccode we get back the libraries that are pickup locations"); >+ > $builder->build_object( > { > class => 'Koha::Item::Transfer::Limits', >-- >2.20.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 26963
:
113282
|
113283
|
113329
|
113330
|
113333
|
113339
|
113340
|
113419
|
113420
|
113422
|
113423
|
113424
|
113425
|
113451
|
113452
|
113453
|
113454
|
113455
|
113480
|
113481
|
113483
|
113498
|
113503
|
113504
|
113505
|
113506
|
113507
|
113508
|
113509
|
113510
|
113511
|
113512
|
113513
|
113514
|
113515
|
113516
|
113517
|
113518
|
113519
|
113520
|
113521
|
113523
|
113524
|
113525
|
113526
|
113527
|
113528
|
113529
|
113530
|
113531
|
113586
|
113729