Bugzilla – Attachment 124133 Details for
Bug 28456
Add option to use a WHERE statement in membership_expiry.pl cronjob
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28456: Add WHERE option to membership_expiry cronjob
Bug-28456-Add-WHERE-option-to-membershipexpiry-cro.patch (text/plain), 4.22 KB, created by
Marcel de Rooy
on 2021-08-27 07:12:34 UTC
(
hide
)
Description:
Bug 28456: Add WHERE option to membership_expiry cronjob
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-08-27 07:12:34 UTC
Size:
4.22 KB
patch
obsolete
>From 2db7691e505b25ef144458e889673c8ee2756ee4 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 25 May 2021 18:46:37 +0000 >Subject: [PATCH] Bug 28456: Add WHERE option to membership_expiry cronjob >Content-Type: text/plain; charset=utf-8 > >Some libraries have a large amount of accounts and want to be able to limit how many email reminders they send. >Adding a where statement will allow for flexibility > >To test: >1 - Set some borrowers to expire soon >2 - Set MembershipExpiryDaysNotice to 10 >3 - perl misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 >4 - Note the patrons that yo uadjusted show up >5 - Limit by various patron fields, e.g. > perl misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 --where="lastseen IS NULL" > perl misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 --where="lastseen IS NOT NULL" > perl misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 --where="surname LIKE '%a%'" > perl misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 --where="surname NOT LIKE '%a%'" >6 - Confirm expected results >7 - perl misc/cronjobs/membership_expiry.pl >8 - Confirm the help message makes sense > >Signed-off-by: Azucena Aguayo <azucena.aguayo@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] Replace two inclue by include. >--- > misc/cronjobs/membership_expiry.pl | 31 ++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 7a043f8e36..41003674e2 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -29,6 +29,18 @@ or, in crontab: > > 0 1 * * * membership_expiry.pl -c > >+Options: >+ --help brief help message >+ --man full documentation >+ --where <conditions> where clause to add to the query >+ -v -verbose verbose mode >+ -n --nomail if supplied messages will be output to STDOUT and not sent >+ -c --confirm commit changes to db, no action will be taken unless this switch is included >+ -b --branch <branchname> only deal with patrons from this library/branch >+ --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 >+ > =head1 DESCRIPTION > > This script sends membership expiry reminder notices to patrons. >@@ -75,15 +87,24 @@ the date set by the preference. > Optional parameter to extend the selection with a number of days AFTER > the date set by the preference. > >+=item B<-where> >+ >+Use this option to specify a condition built with columns from the borrowers table >+ >+e.g. >+--where 'lastseen IS NOT NULL' >+will only notify patrons who have been seen. >+ > =item B<-letter> > >-Optional parameter to use another notice than the default one. >+Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY > > =back > > =head1 CONFIGURATION > >-The content of the messages is configured in Tools -> Notices and slips. Use the MEMBERSHIP_EXPIRY notice. >+The content of the messages is configured in Tools -> Notices and slips. Use the MEMBERSHIP_EXPIRY notice or >+supply another via the parameters. > > Typically, messages are prepared for each patron when the memberships are going to expire. > >@@ -141,6 +162,7 @@ my $man = 0; > my $before = 0; > my $after = 0; > my ( $branch, $letter_type ); >+my @where; > > GetOptions( > 'help|?' => \$help, >@@ -152,6 +174,7 @@ GetOptions( > 'before:i' => \$before, > 'after:i' => \$after, > 'letter:s' => \$letter_type, >+ 'where=s' => \@where, > ) or pod2usage(2); > > pod2usage( -verbose => 2 ) if $man; >@@ -175,6 +198,10 @@ my $upcoming_mem_expires = Koha::Patrons->search_upcoming_membership_expires( > after => $after, > } > ); >+ >+my $where_literal = join ' AND ', @where; >+$upcoming_mem_expires = $upcoming_mem_expires->search( \$where_literal ) if @where; >+ > warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' > if $verbose; > >-- >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 28456
:
121397
|
121922
| 124133