Bugzilla – Attachment 134314 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: Item action trigger
Bug-29346-Item-action-trigger.patch (text/plain), 3.25 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-04-28 22:55:56 UTC
(
hide
)
Description:
Bug 29346: Item action trigger
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-04-28 22:55:56 UTC
Size:
3.25 KB
patch
obsolete
>From 34874e5d8bf8af6ba9d5a0d1bb38623741e47dc2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 23 Mar 2022 12:36:32 -0300 >Subject: [PATCH] Bug 29346: Item action trigger > >This patch makes the following actions trigger a holds queue rebuild for >the related biblio: > >- Adding an item >- Updating an item >- Deleting an item > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Item.t >=> SUCCESS: Tests pass! Background job scheduled >3. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Item.pm | 13 +++++++++++++ > t/db_dependent/Koha/Item.t | 30 +++++++++++++++++++++++++++++- > 2 files changed, 42 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 5760ebc05c..c989a8df37 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -30,6 +30,7 @@ use C4::Reserves; > use C4::ClassSource qw( GetClassSort ); > use C4::Log qw( logaction ); > >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Checkouts; > use Koha::CirculationRules; > use Koha::CoverImages; >@@ -212,6 +213,12 @@ sub store { > unless $params->{skip_record_index}; > $self->get_from_storage->_after_item_action_hooks({ action => $action }); > >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $self->biblionumber ] >+ } >+ ); >+ > return $result; > } > >@@ -237,6 +244,12 @@ sub delete { > logaction( "CATALOGUING", "DELETE", $self->itemnumber, "item" ) > if C4::Context->preference("CataloguingLog"); > >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $self->biblionumber ] >+ } >+ ); >+ > return $result; > } > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 38d3f2234d..3a174dc8bc 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -22,6 +22,7 @@ use utf8; > > use Test::More tests => 15; > use Test::Exception; >+use Test::MockModule; > > use C4::Biblio qw( GetMarcSubfieldStructure ); > use C4::Circulation qw( AddIssue AddReturn ); >@@ -1170,7 +1171,7 @@ subtest 'columns_to_str' => sub { > > subtest 'store() tests' => sub { > >- plan tests => 1; >+ plan tests => 2; > > subtest '_set_found_trigger() tests' => sub { > >@@ -1223,6 +1224,33 @@ subtest 'store() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'holds_queue update tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $biblio->id ], >+ '->store triggers a holds queue update for the related biblio' >+ ); >+ } ); >+ >+ # new item >+ my $item = $builder->build_sample_item({ biblionumber => $biblio->id }); >+ >+ # updated item >+ $item->set({ reserves => 1 })->store; >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'Recalls tests' => sub { >-- >2.34.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 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