Bugzilla – Attachment 155164 Details for
Bug 33522
Optionally skip (in)active patrons when sending membership expiry notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33522: Add active and inactive parameter to membership_expiry.pl
Bug-33522-Add-active-and-inactive-parameter-to-mem.patch (text/plain), 4.50 KB, created by
Marcel de Rooy
on 2023-09-02 07:23:12 UTC
(
hide
)
Description:
Bug 33522: Add active and inactive parameter to membership_expiry.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-09-02 07:23:12 UTC
Size:
4.50 KB
patch
obsolete
>From a63d4b836be31aa021fe180f621d299e26b08415 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 30 May 2023 15:04:28 +0000 >Subject: [PATCH] Bug 33522: Add active and inactive parameter to > membership_expiry.pl >Content-Type: text/plain; charset=utf-8 > >Test plan: >Enable TrackLastPatronActivity. >Set MembershipExpiryDaysNotice to X days. >Pick a patron, make it expire in X days. Add email address. >Update borrowers.lastseen for this patron to make it active. >Run membership_expiry.pl -c -v -active 6 >You should see at least one enqueued notice. >Run membership_expiry.pl -c -v -inactive 6 >You should see that it skipped a number of active patrons (>=1). > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > misc/cronjobs/membership_expiry.pl | 38 +++++++++++++++++++++++++++++- > 1 file changed, 37 insertions(+), 1 deletion(-) > >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 939b6e0f40..e8485663e1 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -2,7 +2,8 @@ > > # This file is part of Koha. > # >-# Copyright (C) 2015 Amit Gupta (amitddng135@gmail.com) >+# Copyright 2023 Koha development team >+# Copyright 2015 Amit Gupta (amitddng135@gmail.com) > # > # Koha is free software; you can redistribute it and/or modify it > # under the terms of the GNU General Public License as published by >@@ -40,6 +41,8 @@ Options: > --before=X include patrons expiring a number of days BEFORE the date set by the preference > --after=X include patrons expiring a number of days AFTER the date set by the preference > -l --letter <lettercode> use a specific notice rather than the default >+ --active=X only send notices to active patrons (active within X months) >+ --inactive=X only send notices to inactive patrons (inactive within X months) > > =head1 DESCRIPTION > >@@ -99,6 +102,15 @@ will only notify patrons who have been seen. > > Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY > >+=item B<-active> >+ >+Optional parameter to include active patrons only (active within passed number of months). >+ >+=item B<-inactive> >+ >+Optional parameter to include inactive patrons only (inactive within passed number of months). >+This allows you to skip active patrons when you renew them automatically (see bug 28688). >+ > =back > > =head1 CONFIGURATION >@@ -157,6 +169,8 @@ my $before = 0; > my $after = 0; > my ( $branch, $letter_type ); > my @where; >+my $active; >+my $inactive; > > my $command_line_options = join(" ",@ARGV); > >@@ -171,10 +185,16 @@ GetOptions( > 'after:i' => \$after, > 'letter:s' => \$letter_type, > 'where=s' => \@where, >+ 'active:i' => \$active, >+ 'inactive:i' => \$inactive, > ) or pod2usage(2); > > pod2usage( -verbose => 2 ) if $man; > pod2usage(1) if $help || !$confirm; >+if( defined($active) && defined($inactive) ) { >+ print "Sorry, it is not possible to pass both -active as well as -inactive.\n"; >+ exit; >+} > > cronlogaction({ info => $command_line_options }); > >@@ -203,7 +223,16 @@ warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' > > # main loop > $letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; >+my ( $count_active, $count_inactive, $count_enqueued ) = ( 0, 0, 0 ); > while ( my $recent = $upcoming_mem_expires->next ) { >+ my $patron_active = $recent->is_active({ months => $active // $inactive }); # checked already that only one is defined >+ if( defined($active) && !$patron_active ) { >+ $count_inactive++; >+ next; >+ } elsif( defined($inactive) && $patron_active ) { >+ $count_active++; >+ next; >+ } > my $from_address = $recent->library->from_email_address; > my $letter = C4::Letters::GetPreparedLetter( > module => 'members', >@@ -227,6 +256,7 @@ while ( my $recent = $upcoming_mem_expires->next ) { > from_address => $from_address, > message_transport_type => 'email', > }); >+ $count_enqueued++; > > if ($recent->smsalertnumber) { > my $smsletter = C4::Letters::GetPreparedLetter( >@@ -250,4 +280,10 @@ while ( my $recent = $upcoming_mem_expires->next ) { > } > } > >+if( $verbose ) { >+ print "Enqueued notices for $count_enqueued patrons\n"; >+ print "Skipped $count_active active patrons\n" if $count_active; >+ print "Skipped $count_inactive inactive patrons\n" if $count_inactive; >+} >+ > cronlogaction({ action => 'End', info => "COMPLETED" }); >-- >2.30.2
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 33522
:
151885
|
151986
|
155164
|
155165
|
156531
|
156532