From d2610f39c7bbdcf086b21f204c21a7167cefe10b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 12 Oct 2017 15:36:10 +0200 Subject: [PATCH] Bug 19454: Add -category parameter to borrowers-force-messaging-defaults.pl Instead of updating patrons over all patron categories, it would be helpful if we could filter on a specified category. Test plan: [1] Select two patrons A and B in say categories C1 and C2. [2] Change the msg prefs for A and B away from defaults. [3] Run borrowers-force-messaging-defaults.pl -doit -cat C1 Verify that patron A changed and patron B did not. Signed-off-by: Marcel de Rooy Signed-off-by: Charles Farmer Amended: Replace -category by --category. (marcelr 20180314) Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../borrowers-force-messaging-defaults.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl index bd7a00fa21..897f5dfcbc 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, $since, $not_expired, $no_overwrite) = @_; + my ($doit, $since, $not_expired, $no_overwrite, $category ) = @_; $since = '0000-00-00' if (!$since); print "Since: $since\n"; @@ -57,8 +57,9 @@ WHERE bo.dateenrolled >= ?|; if( $no_overwrite ) { $sql .= " AND mp.borrowernumber IS NULL"; } + $sql .= " AND categorycode = ?" if $category; my $sth = $dbh->prepare($sql); - $sth->execute($since); + $sth->execute($since, $category || () ); while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { print "$borrowernumber: $categorycode\n"; next unless $doit; @@ -71,18 +72,19 @@ WHERE bo.dateenrolled >= ?|; } -my ( $doit, $since, $help, $not_expired, $no_overwrite ); +my ( $doit, $since, $help, $not_expired, $no_overwrite, $category ); my $result = GetOptions( 'doit' => \$doit, 'since:s' => \$since, 'not-expired' => \$not_expired, 'no-overwrite' => \$no_overwrite, + 'category:s' => \$category, 'help|h' => \$help, ); usage() if $help; -force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite ); +force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category ); =head1 NAME @@ -94,6 +96,7 @@ borrowers-force-messaging-defaults.pl borrowers-force-messaging-defaults.pl --help borrowers-force-messaging-defaults.pl --doit borrowers-force-messaging-defaults.pl --doit --not-expired + borrowers-force-messaging-defaults.pl --doit --category PT =head1 DESCRIPTION @@ -126,6 +129,10 @@ Will only update active borrowers (borrowers who didn't pass their expiration da Will only update patrons without messaging preferences and skip patrons that already set their preferences. +=item B<--category> + +Will only update patrons in the category specified. + =back =cut -- 2.39.5