Bugzilla – Attachment 126319 Details for
Bug 24609
Add routes for updating checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24609: Add trigger to set items.onloan on due_date update
Bug-24609-Add-trigger-to-set-itemsonloan-on-duedat.patch (text/plain), 1.87 KB, created by
Tomás Cohen Arazi
on 2021-10-15 11:51:24 UTC
(
hide
)
Description:
Bug 24609: Add trigger to set items.onloan on due_date update
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2021-10-15 11:51:24 UTC
Size:
1.87 KB
patch
obsolete
>From a7b676c63f4aa3fa284e647c121789b637c79f31 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 13 Oct 2021 14:02:47 +0100 >Subject: [PATCH] Bug 24609: Add trigger to set items.onloan on due_date update > >This patch adds an overridden store method to Koha::Checkout to catch >due_date changes and trigger an update of the items.onloan field. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Checkout.pm | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > >diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm >index cc00194248..041cba9c65 100644 >--- a/Koha/Checkout.pm >+++ b/Koha/Checkout.pm >@@ -42,6 +42,39 @@ Koha::Checkout - Koha Checkout object class > > =cut > >+=head3 store >+ >+ $item->store; >+ >+$params can take an optional 'skip_record_index' parameter. >+If set, the reindexation process will not happen (index_records not called) >+ >+NOTE: This is a temporary fix to answer a performance issue when lot of checkout >+dates change which would result in lots of items onloan dates changing. >+The correct way to fix this is to make the ES reindexation process async. >+You should not turn it on if you do not understand what it is doing exactly. >+ >+=cut >+ >+sub store { >+ my $self = shift; >+ my $params = @_ ? shift : {}; >+ >+ # Update >+ if ( $self->in_storage ) { >+ my %updated_columns = $self->_result->get_dirty_columns; >+ return $self->SUPER::store unless %updated_columns; >+ >+ # If checkout due_date was updated, trigger the item onloan date change >+ if ( exists $updated_columns{date_due} ) { >+ $self->item->onloan( $updated_columns{date_due} ) >+ ->store( { skip_record_index => $params->{skip_record_index} } ); >+ } >+ } >+ >+ return $self->SUPER::store; >+} >+ > =head3 is_overdue > > my $is_overdue = $checkout->is_overdue( [ $reference_dt ] ); >-- >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 24609
:
98924
|
98925
|
99021
|
99022
|
115879
|
115880
|
115881
|
126191
|
126192
|
126193
|
126194
|
126316
|
126317
|
126318
|
126319
|
126320
|
126321
|
126917
|
126921
|
126922
|
126923
|
126924
|
126925
|
126926
|
126927
|
126928