Bugzilla – Attachment 127904 Details for
Bug 29474
Automatic renewals cronjob is slow on systems with large numbers of reserves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29474: Decouple renewal checks of auto-renewed issues from non-autorenewed
Bug-29474-Decouple-renewal-checks-of-auto-renewed-.patch (text/plain), 3.45 KB, created by
Joonas Kylmälä
on 2021-11-20 12:14:12 UTC
(
hide
)
Description:
Bug 29474: Decouple renewal checks of auto-renewed issues from non-autorenewed
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-11-20 12:14:12 UTC
Size:
3.45 KB
patch
obsolete
>From 3bb6843006dc04faaff7be3b26b93bc5c5eb3cc9 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@iki.fi> >Date: Sun, 14 Nov 2021 12:05:16 +0000 >Subject: [PATCH] Bug 29474: Decouple renewal checks of auto-renewed issues > from non-autorenewed > >The too_soon check does not relate at all to auto-renewed issues and >should be moved outside the _CanBookBeAutoRenewed() function. > >To test: > 1) prove t/db_dependent/Circulation.t >--- > C4/Circulation.pm | 40 +++++++++++++--------------------------- > 1 file changed, 13 insertions(+), 27 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 1ba9dfaaba..ccd0c02287 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2795,7 +2795,7 @@ sub CanBookBeRenewed { > branchcode => $branchcode, > issue => $issue > }); >- return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon' && $cron; >+ return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_soon' && $cron; > # cron wants 'too_soon' over 'on_reserve' for performance and to avoid > # extra notices being sent. Cron also implies no override > return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired'; >@@ -2864,6 +2864,9 @@ sub CanBookBeRenewed { > > return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found > return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; >+ if ( GetSoonestRenewDate($borrowernumber, $itemnumber) > dt_from_string() ){ >+ return (0, "too_soon") unless $override_limit; >+ } > > return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed > >@@ -4311,35 +4314,18 @@ sub _CanBookBeAutoRenewed { > return "auto_too_much_oweing"; > } > } >- } >- >- if ( defined $issuing_rule->{norenewalbefore} >- and $issuing_rule->{norenewalbefore} ne "" ) >- { > >- # Calculate soonest renewal by subtracting 'No renewal before' from due date >- my $soonestrenewal = dt_from_string( $issue->date_due, 'sql' )->subtract( >- $issuing_rule->{lengthunit} => $issuing_rule->{norenewalbefore} ); >- >- # Depending on syspref reset the exact time, only check the date >- if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' >- and $issuing_rule->{lengthunit} eq 'days' ) >- { >- $soonestrenewal->truncate( to => 'day' ); >- } >- >- if ( $soonestrenewal > dt_from_string() ) >- { >- return ($issue->auto_renew && $patron->autorenew_checkouts) ? "auto_too_soon" : "too_soon"; >- } >- elsif ( $issue->auto_renew && $patron->autorenew_checkouts ) { >- return "ok"; >+ if ( defined $issuing_rule->{norenewalbefore} >+ and $issuing_rule->{norenewalbefore} ne "" ) { >+ if ( GetSoonestRenewDate($patron->id, $item->id) > dt_from_string()) { >+ return "auto_too_soon"; >+ } else { >+ return "ok"; >+ } > } >- } > >- # Fallback for automatic renewals: >- # If norenewalbefore is undef, don't renew before due date. >- if ( $issue->auto_renew && $patron->autorenew_checkouts ) { >+ # Fallback for automatic renewals: >+ # If norenewalbefore is undef, don't renew before due date. > my $now = dt_from_string; > if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){ > return "ok"; >-- >2.20.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 29474
:
127610
|
127611
|
127612
|
127613
|
127614
|
127615
|
127616
|
127617
|
127632
|
127633
|
127634
|
127635
|
127658
|
127903
|
127904
|
127905
|
127906
|
127907
|
127949
|
127950
|
127951
|
127952
|
127953
|
128554
|
128555
|
128556