Bugzilla – Attachment 134343 Details for
Bug 29346
Real-time holds queue update
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29346: (follow-up) Build holds queue when AlterPriority or RevertWaitingStatus is called
Bug-29346-follow-up-Build-holds-queue-when-AlterPr.patch (text/plain), 5.29 KB, created by
Nick Clemens (kidclamp)
on 2022-04-29 01:03:50 UTC
(
hide
)
Description:
Bug 29346: (follow-up) Build holds queue when AlterPriority or RevertWaitingStatus is called
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-04-29 01:03:50 UTC
Size:
5.29 KB
patch
obsolete
>From e4cdb3f39475cb3450474c1a09bdaa2aeaa77c12 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 29 Apr 2022 00:56:25 +0000 >Subject: [PATCH] Bug 29346: (follow-up) Build holds queue when AlterPriority > or RevertWaitingStatus is called > >To test: >1 - Place 3 holds on a bib with a single item >2 - Confirm bib shows in holds queue >3 - Check in item and cnofirm hold >4 - Bib is no longer in queue >5 - Revert the waiting status >6 - The hold is in the queue again >7 - Move top hold to bottom >8 - Confirm queue selects hold for new top priorty patron > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Reserves.pm | 12 +++++++ > t/db_dependent/Reserves.t | 70 +++++++++++++++++++++++++++++++++++++-- > 2 files changed, 79 insertions(+), 3 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 2885382cc6..223552f943 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1435,6 +1435,11 @@ sub AlterPriority { > _FixPriority({ reserve_id => $reserve_id, rank => $last_priority }); > } > >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $hold->biblionumber ] >+ } >+ ); > # FIXME Should return the new priority > } > >@@ -2083,6 +2088,13 @@ sub RevertWaitingStatus { > > _FixPriority( { biblionumber => $hold->biblionumber } ); > >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $hold->biblionumber ] >+ } >+ ); >+ >+ > return $hold; > } > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index c93987e17a..cfac978aeb 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 70; >+use Test::More tests => 71; > use Test::MockModule; > use Test::Warn; > >@@ -31,7 +31,7 @@ use C4::Circulation qw( AddReturn AddIssue ); > use C4::Items; > use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblio ); > use C4::Members; >-use C4::Reserves qw( AddReserve CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds ); >+use C4::Reserves qw( AddReserve AlterPriority CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds ); > use Koha::ActionLogs; > use Koha::Caches; > use Koha::DateUtils qw( dt_from_string output_pref ); >@@ -934,7 +934,7 @@ subtest 'reserves.item_level_hold' => sub { > ); > > subtest 'item level hold' => sub { >- plan tests => 2; >+ plan tests => 3; > my $reserve_id = AddReserve( > { > branchcode => $item->homebranch, >@@ -951,6 +951,16 @@ subtest 'reserves.item_level_hold' => sub { > # Mark it waiting > ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); > >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $hold->biblionumber ], >+ "AlterPriority triggers a holds queue update for the related biblio" >+ ); >+ } ); >+ > # Revert the waiting status > C4::Reserves::RevertWaitingStatus( > { itemnumber => $item->itemnumber } ); >@@ -1428,3 +1438,57 @@ subtest 'AddReserve() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'AlterPriorty() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_1->id, >+ biblionumber => $biblio->id, >+ } >+ ); >+ AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_2->id, >+ biblionumber => $biblio->id, >+ } >+ ); >+ AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_3->id, >+ biblionumber => $biblio->id, >+ } >+ ); >+ >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $biblio->id ], >+ "AlterPriority triggers a holds queue update for the related biblio" >+ ); >+ } ); >+ >+ >+ AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ is($hold->priority,3,'Successfully altered priority to bottom'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 29346
:
131088
|
131089
|
131811
|
131812
|
131813
|
131815
|
132078
|
132079
|
132080
|
132081
|
132082
|
132083
|
133183
|
133184
|
133185
|
133186
|
133187
|
133188
|
133189
|
133190
|
133191
|
133205
|
133991
|
133992
|
133993
|
133994
|
133995
|
133996
|
133997
|
133998
|
133999
|
134000
|
134001
|
134010
|
134225
|
134227
|
134309
|
134310
|
134311
|
134312
|
134313
|
134314
|
134315
|
134316
|
134317
|
134318
|
134319
|
134320
|
134321
|
134322
|
134328
|
134329
|
134330
|
134331
|
134332
|
134333
|
134334
|
134335
|
134336
|
134337
|
134338
|
134339
|
134340
|
134341
|
134342
| 134343