Bugzilla – Attachment 131815 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: Circulation actions triggers
Bug-29346-Circulation-actions-triggers.patch (text/plain), 4.18 KB, created by
Tomás Cohen Arazi
on 2022-03-16 21:09:07 UTC
(
hide
)
Description:
Bug 29346: Circulation actions triggers
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2022-03-16 21:09:07 UTC
Size:
4.18 KB
patch
obsolete
>From ae6d0e36d1faa7c0f319a5a2f997dc36db8681ca Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 16 Mar 2022 18:05:55 -0300 >Subject: [PATCH] Bug 29346: Circulation actions triggers > >This patch introduces triggers for real-time updating the holds queue at >check out and check in. > >The following high-level methods are involved: > >- C4::Circulation::AddIssue >- C4::Circulation::AddReturn > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Circulation_holdsqueue.t >=> SUCCESS: Tests pass! Triggers are triggered >3. Sign off :-D > >Note: I put the tests on a separate file because the other one was too >big already. > >Sponsored-by: Montgomery County Public Libraries >--- > C4/Circulation.pm | 13 +++++ > t/db_dependent/Circulation_holdsqueue.t | 64 +++++++++++++++++++++++++ > 2 files changed, 77 insertions(+) > create mode 100755 t/db_dependent/Circulation_holdsqueue.t > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 5537531db2..5a7149c1bb 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -41,6 +41,7 @@ use Algorithm::CheckDigits qw( CheckDigits ); > use Data::Dumper qw( Dumper ); > use Koha::Account; > use Koha::AuthorisedValues; >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Biblioitems; > use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Calendar; >@@ -1765,6 +1766,12 @@ sub AddIssue { > checkout => $issue->get_from_storage > } > }); >+ >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $item_object->biblionumber ] >+ } >+ ); > } > } > return $issue; >@@ -2425,6 +2432,12 @@ sub AddReturn { > checkout=> $checkin > } > }); >+ >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $item->biblionumber ] >+ } >+ ); > } > > return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} )); >diff --git a/t/db_dependent/Circulation_holdsqueue.t b/t/db_dependent/Circulation_holdsqueue.t >new file mode 100755 >index 0000000000..f8a82ffd19 >--- /dev/null >+++ b/t/db_dependent/Circulation_holdsqueue.t >@@ -0,0 +1,64 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::MockModule; >+ >+use C4::Circulation qw( AddIssue AddReturn ); >+ >+use Koha::Database; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item({ library => $library->id }); >+ >+ t::lib::Mocks::mock_userenv({ branchcode => $library->id }); >+ >+ my $action; >+ >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $item->biblionumber ], >+ "$action triggers a holds queue update for the related biblio" >+ ); >+ } ); >+ >+ $action = 'AddIssue'; >+ AddIssue( $patron->unblessed, $item->barcode, ); >+ >+ $action = 'AddReturn'; >+ AddReturn( $item->barcode ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.32.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 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