From 95ebfa1f2946046d12dbfc1a13e8171b890f0249 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 2 Sep 2022 07:52:15 +0000 Subject: [PATCH] Bug 30755: (follow-up) Add a results hash to automatic renewals It's slightly debatable whether auto_too_soon is an error or not. I think it leans far enough towards error that the other patch is correct. The change, however, will affect notices and means we cannot count auto_too_soon anymore This patch adds a new 'results' hash to the info - this includes a count per error (including auto_renew i.e. success) allowing for notices to decide how to display the info. To test: 1 - Add to Auto renew digest notice: [% IF results %] There were [% results.auto_too_soon %] items that were too soon. [% END %] 2 - Check out some items to a patron that will be too soon 3 - Check out one that is not too soon and will renew 4 - Ensure patron has auto renew digest selected and that AutoRenewalNotices is set to follow patron preferences 5 - Run the auto renewals cron 6 - Confirm the notice for the patron displays 1 successful renewal, no failures, and a correct count of too_soon Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- misc/cronjobs/automatic_renewals.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index 288940ed23..0749ed5c0d 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -210,11 +210,13 @@ while ( my $auto_renew = $auto_renews->next ) { if ($digest_per_branch) { $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon'; + $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{results}->{$error}++ ; push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; } else { $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon'; + $renew_digest->{ $auto_renew->borrowernumber }->{results}->{$error}++ ; $renew_digest->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; } @@ -344,6 +346,7 @@ sub send_digests { substitute => { error => $digest->{error}||0, success => $digest->{success}||0, + results => $digest->{results}, }, loops => { issues => \@{$digest->{issues}} }, tables => { -- 2.39.5