Bugzilla – Attachment 31631 Details for
Bug 12803
Add ability to skip closed libraries when generating the holds queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12803 - Enable feature when using Transport Cost Matrix
Bug-12803---Enable-feature-when-using-Transport-Co.patch (text/plain), 5.42 KB, created by
Melissa Lefebvre
on 2014-09-16 13:30:27 UTC
(
hide
)
Description:
Bug 12803 - Enable feature when using Transport Cost Matrix
Filename:
MIME Type:
Creator:
Melissa Lefebvre
Created:
2014-09-16 13:30:27 UTC
Size:
5.42 KB
patch
obsolete
>From 0b31c92fc33a65adece4be6437640aabb4fce605 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 21 Aug 2014 12:31:57 -0400 >Subject: [PATCH] Bug 12803 - Enable feature when using Transport Cost Matrix > >Test plan: repeat test plan for first patch, but use transport cost >matrix > >Signed-off by: Jason Robb <jrobb@sekls.org> > >--- > C4/HoldsQueue.pm | 20 ++++++++++++++++---- > t/db_dependent/HoldsQueue.t | 36 ++++++++++++++++++++++++------------ > 2 files changed, 40 insertions(+), 16 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index ca68a10..7090c08 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -67,13 +67,25 @@ sub TransportCostMatrix { > my $dbh = C4::Context->dbh; > my $transport_costs = $dbh->selectall_arrayref("SELECT * FROM transport_cost",{ Slice => {} }); > >+ my $today = dt_from_string(); >+ my $calendars; > my %transport_cost_matrix; > foreach (@$transport_costs) { >- my $from = $_->{frombranch}; >- my $to = $_->{tobranch}; >- my $cost = $_->{cost}; >+ my $from = $_->{frombranch}; >+ my $to = $_->{tobranch}; >+ my $cost = $_->{cost}; > my $disabled = $_->{disable_transfer}; >- $transport_cost_matrix{$to}{$from} = { cost => $cost, disable_transfer => $disabled }; >+ $transport_cost_matrix{$to}{$from} = { >+ cost => $cost, >+ disable_transfer => $disabled >+ }; >+ >+ if ( C4::Context->preference("HoldsQueueSkipClosed") ) { >+ $calendars->{$from} ||= C4::Calendar->new( branchcode => $from ); >+ $transport_cost_matrix{$to}{$from}{disable_transfer} ||= >+ $calendars->{$from}->isHoliday( $today->day(), $today->month(), $today->year() ); >+ } >+ > } > return \%transport_cost_matrix; > } >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 5c63b43..c9aa435 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -8,7 +8,7 @@ > > use Modern::Perl; > >-use Test::More tests => 22; >+use Test::More tests => 23; > use Data::Dumper; > > use C4::Context; >@@ -53,6 +53,7 @@ my $itemtype = grep { $_->{notforloan} == 1 } @item_types > > #Set up the stage > # Sysprefs and cost matrix >+C4::Context->set_preference('HoldsQueueSkipClosed', 0); > $dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, > join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); > $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); >@@ -289,19 +290,12 @@ ok( @$holds_queue == 2, "Holds queue filling correct number for default holds po > ok( $holds_queue->[0]->{cardnumber} eq 'CARDNUMBER1', "Holds queue filling 1st correct hold for default holds policy 'from home library'"); > ok( $holds_queue->[1]->{cardnumber} eq 'CARDNUMBER2', "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); > >-$dbh->do("DELETE FROM default_circ_rules"); >-$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); >-C4::HoldsQueue::CreateQueue(); >-$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); >-ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); >-#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); >- > # Test skipping hold picks for closed libraries. >-# At this point in the test, we have 3 rows in the holds queue >-# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed >+# At this point in the test, we have 2 rows in the holds queue >+# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed > # and make today a holiday for MPL. When we run it again we should only >-# have 2 rows in the holds queue >-C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 ); >+# have 1 row in the holds queue >+C4::Context->set_preference('HoldsQueueSkipClosed', 1); > my $today = dt_from_string(); > C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( > day => $today->day(), >@@ -312,6 +306,24 @@ C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( > ); > C4::HoldsQueue::CreateQueue(); > $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); >+ok( @$holds_queue == 1, "Holds not filled with items from closed libraries" ); >+C4::Context->set_preference('HoldsQueueSkipClosed', 0); >+ >+$dbh->do("DELETE FROM default_circ_rules"); >+$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); >+C4::HoldsQueue::CreateQueue(); >+$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); >+ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); >+#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); >+ >+# Test skipping hold picks for closed libraries without transport cost matrix >+# At this point in the test, we have 3 rows in the holds queue >+# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed >+# and use our previously created holiday for MPL. >+# When we run it again we should only have 2 rows in the holds queue >+C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 ); >+C4::HoldsQueue::CreateQueue(); >+$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); > ok( @$holds_queue == 2, "Holds not filled with items from closed libraries" ); > > # Cleanup >-- >1.7.2.5
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 12803
:
31057
|
31060
|
31061
|
31062
|
31063
|
31630
|
31631
|
32046
|
32271
|
43509
|
43510
|
43511
|
43512
|
43610
|
43779
|
43833
|
43979
|
45569
|
45570
|
45571
|
45572
|
45573
|
45574
|
45575
|
45576
|
45638
|
45643
|
45644
|
46888
|
46889
|
46890
|
46891
|
46892
|
46893
|
46894
|
46895
|
47246
|
47247
|
48574
|
48575