Bugzilla – Attachment 68200 Details for
Bug 19451
Let borrowers-force-messaging-defaults.pl optionally add preferences only when not already present
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19451: Add no_overwrite option to borrowers-force-messaging-defaults.pl
Bug-19451-Add-nooverwrite-option-to-borrowers-forc.patch (text/plain), 3.83 KB, created by
Marcel de Rooy
on 2017-10-17 12:21:08 UTC
(
hide
)
Description:
Bug 19451: Add no_overwrite option to borrowers-force-messaging-defaults.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-10-17 12:21:08 UTC
Size:
3.83 KB
patch
obsolete
>From 2e03f503451fb6b04b481e217e54c1f7bf877dce Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 12 Oct 2017 12:19:11 +0200 >Subject: [PATCH] Bug 19451: Add no_overwrite option to > borrowers-force-messaging-defaults.pl >Content-Type: text/plain; charset=utf-8 > >This option allows you to add preferences only when they are not yet >present. In other words: skip patrons that already set their prefs. > >Test plan: >[1] Delete all borrower messaging prefs for a patron. >[2] Run borrowers-force-messaging-defaults.pl -no_overwrite -doit > Verify that the patron now has default msg preferences. >[3] Change his settings and make them non-default. > For instance, increase days in advance. >[4] Run borrowers-force-messaging-defaults.pl -no_overwrite -doit > Verify that the patron still has the non-default settings. >[5] Run borrowers-force-messaging-defaults.pl -doit > Verify that the patron msg prefs have been overwritten. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../borrowers-force-messaging-defaults.pl | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > >diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl >index e21b562..4a1f42d 100755 >--- a/misc/maintenance/borrowers-force-messaging-defaults.pl >+++ b/misc/maintenance/borrowers-force-messaging-defaults.pl >@@ -39,7 +39,7 @@ sub usage { > > > sub force_borrower_messaging_defaults { >- my ($doit, $truncate, $since, $not_expired) = @_; >+ my ($doit, $truncate, $since, $not_expired, $no_overwrite) = @_; > > $since = '0000-00-00' if (!$since); > print "Since: $since\n"; >@@ -54,10 +54,13 @@ sub force_borrower_messaging_defaults { > $dbh->do(q|SET FOREIGN_KEY_CHECKS = 1|); > } > >- my $sql = "SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?"; >+ my $sql = "SELECT borrowernumber, categorycode FROM borrowers bo WHERE dateenrolled >= ?"; > if ($not_expired) { > $sql .= " AND dateexpiry >= NOW()" > } >+ if( $no_overwrite ) { >+ $sql .= " AND (SELECT COUNT(*) FROM borrower_message_preferences mp WHERE mp.borrowernumber=bo.borrowernumber) = 0" >+ } > my $sth = $dbh->prepare($sql); > $sth->execute($since); > while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { >@@ -72,18 +75,19 @@ sub force_borrower_messaging_defaults { > } > > >-my ($doit, $truncate, $since, $help, $not_expired); >+my ( $doit, $truncate, $since, $help, $not_expired, $no_overwrite ); > my $result = GetOptions( > 'doit' => \$doit, > 'truncate' => \$truncate, > 'since:s' => \$since, > 'not-expired' => \$not_expired, >+ 'no_overwrite' => \$no_overwrite, > 'help|h' => \$help, > ); > > usage() if $help; > >-force_borrower_messaging_defaults( $doit, $truncate, $since, $not_expired ); >+force_borrower_messaging_defaults( $doit, $truncate, $since, $not_expired, $no_overwrite ); > > =head1 NAME > >@@ -105,8 +109,9 @@ preferences default values as defined for their borrower category. So you would > have to modify each borrower one by one if you would like to send them 'Hold > Filled' notice for example. > >-This script create transport preferences for all existing borrowers and set >-them to default values defined for the category they belong to. >+This script creates/overwrites messaging preferences for all borrowers and sets >+them to default values defined for the category they belong to (unless you >+use the options -not-expired or -no_overwrite to update a subset). > > =over 8 > >@@ -127,6 +132,11 @@ affects borrower_message_preferences table. > > Will only update active borrowers (borrowers who didn't pass their expiration date). > >+=item B<--no_overwrite> >+ >+Will only update patrons without messaging preferences and skip patrons that >+already set their preferences. >+ > =back > > =cut >-- >2.1.4
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 19451
:
67989
|
68200
|
68844
|
71327
|
71328
|
71367