Bugzilla – Attachment 67989 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.79 KB, created by
Marcel de Rooy
on 2017-10-12 10:49:55 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-12 10:49:55 UTC
Size:
3.79 KB
patch
obsolete
>From 751c3b5bab3799d14bac82d16bd6ab1920fcc6f3 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 1bca97d..cbff4f1 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, $actives) = @_; >+ my ($doit, $truncate, $since, $actives, $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 ($actives) { > $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, $actives); >+my ( $doit, $truncate, $since, $help, $actives, $no_overwrite ); > my $result = GetOptions( > 'doit' => \$doit, > 'truncate' => \$truncate, > 'since:s' => \$since, > 'actives' => \$actives, >+ 'no_overwrite' => \$no_overwrite, > 'help|h' => \$help, > ); > > usage() if $help; > >-force_borrower_messaging_defaults( $doit, $truncate, $since, $actives ); >+force_borrower_messaging_defaults( $doit, $truncate, $since, $actives, $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 -actives 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