Bugzilla – Attachment 132206 Details for
Bug 30222
Auto_renew_digest still sends every day when renewals are not allowed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30222: Simplify logic for reporting
Bug-30222-Simplify-logic-for-reporting.patch (text/plain), 4.91 KB, created by
Jonathan Druart
on 2022-03-25 08:09:07 UTC
(
hide
)
Description:
Bug 30222: Simplify logic for reporting
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-03-25 08:09:07 UTC
Size:
4.91 KB
patch
obsolete
>From 559dd0fd4cfa551a8edf3bd9295db30598790b7a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 11 Mar 2022 13:24:33 +0000 >Subject: [PATCH] Bug 30222: Simplify logic for reporting > >This patch adds two new variables: >$wants_email and $wants digest > >These are used to simplify checks on whether notices should be sent > >To test: >1 - Apply patch >2 - Confirm notices are not sent of pref is 'cron' and send_notcies flag not set >3 - Confirm notices are sent if pref is cron and send_notices flag is set and borrower > does not have preference set for auto renewals >4 - Confirm notices not sent if pref is set to follow messaging preference and borrower > does not have preferences set for auto_renewals >5 - Confirm regular notices sent if pref is set to follow messaging preferences and borrower > does have the preference set but not digest >6 - Confirm digest notices sent if pref is set to follow messaging preferences and borrower > does have the preference set and wants digest > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > misc/cronjobs/automatic_renewals.pl | 30 ++++++++++++++++++++++------- > 1 file changed, 23 insertions(+), 7 deletions(-) > >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 6e8ad4fa51e..e3593300b43 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -140,11 +140,26 @@ my %report; > while ( my $auto_renew = $auto_renews->next ) { > print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose; > >- my $borrower_preferences; >- $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, >- message_name => 'auto_renewals' } ) if $send_notices_pref eq 'preferences'; >+ my ( $borrower_preferences, $wants_email, $wants_digest ); >+ if ( $send_notices_pref eq 'preferences' ){ >+ $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( >+ { >+ borrowernumber => $auto_renew->borrowernumber, >+ message_name => 'auto_renewals' >+ } >+ ); >+ $wants_email = 1 >+ if $borrower_preferences >+ && $borrower_preferences->{transports} >+ && $borrower_preferences->{transports}->{email}; >+ $wants_digest = 1 >+ if $wants_email >+ && $borrower_preferences->{wants_digest}; >+ } > >- $send_notices = 1 if !$send_notices && $send_notices_pref eq 'preferences' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email}; >+ $send_notices = 1 >+ if !$send_notices >+ && $wants_email; > > # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script > my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 ); >@@ -159,7 +174,8 @@ while ( my $auto_renew = $auto_renews->next ) { > my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); > $auto_renew->auto_renew_error(undef)->store; > } >- push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $send_notices_pref ne 'cron' && (!$borrower_preferences || !$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); >+ push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >+ if $send_notices && !$wants_digest; > } elsif ( $error eq 'too_many' > or $error eq 'on_reserve' > or $error eq 'restriction' >@@ -178,11 +194,11 @@ while ( my $auto_renew = $auto_renews->next ) { > if ( not $auto_renew->auto_renew_error or $updated ) { > $auto_renew->auto_renew_error($error)->store if $confirm; > push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >- if $error ne 'auto_too_soon' && ($send_notices_pref eq 'cron' || ($borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'})); # Do not notify if it's too soon >+ if $error ne 'auto_too_soon' && ( $send_notices && !$wants_digest ); # Do not notify if it's too soon > } > } > >- if ( $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && $borrower_preferences->{'wants_digest'} ) { >+ if ( $wants_digest ) { > # cache this one to process after we've run through all of the items. > if ($digest_per_branch) { > $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; >-- >2.25.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 30222
:
131586
|
131587
|
131659
|
131660
|
131662
|
131663
|
131721
|
131728
|
131729
|
131730
|
132205
| 132206 |
132207
|
132208
|
132209