Bugzilla – Attachment 18990 Details for
Bug 10419
There is no cronjob script for deleting patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10419: Followup - Script for deleting patrons
Bug-10419-Followup---Script-for-deleting-patrons.patch (text/plain), 3.23 KB, created by
Kyle M Hall (khall)
on 2013-06-14 12:02:59 UTC
(
hide
)
Description:
Bug 10419: Followup - Script for deleting patrons
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-06-14 12:02:59 UTC
Size:
3.23 KB
patch
obsolete
>From a7f86d0e86f80da96339786f29771f2d307ad5a9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 7 Jun 2013 15:51:43 +0200 >Subject: [PATCH] Bug 10419: Followup - Script for deleting patrons > >This followup adds: >- execute flag (+x) for the cronjob script. >- replaces --dry-run with --confirm (according with existing scripts). >- changes output text (remove 'first person' style). >- updates the doc and simplifies the dates parameters. >- changes flags PrintError and RaiseError for the dbh in order to catch > something if an error occurs... > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > misc/cronjobs/delete_patrons.pl | 27 +++++++++++++++++---------- > 1 files changed, 17 insertions(+), 10 deletions(-) > mode change 100644 => 100755 misc/cronjobs/delete_patrons.pl > >diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl >old mode 100644 >new mode 100755 >index ad3c875..2d869f5 >--- a/misc/cronjobs/delete_patrons.pl >+++ b/misc/cronjobs/delete_patrons.pl >@@ -9,14 +9,14 @@ use C4::Members; > use Koha::DateUtils; > > my ( $help, $verbose, $not_borrowered_since, $expired_before, $category_code, >- $dryrun ); >+ $confirm ); > GetOptions( > 'h|help' => \$help, > 'v|verbose' => \$verbose, > 'not_borrowered_since:s' => \$not_borrowered_since, > 'expired_before:s' => \$expired_before, > 'category_code:s' => \$category_code, >- 'dry-run' => \$dryrun, >+ 'c|confirm' => \$confirm, > ) || pod2usage(1); > > if ($help) { >@@ -42,20 +42,25 @@ my $members = GetBorrowersToExpunge( > } > ); > >-say "I found " . scalar(@$members) . " patrons to delete"; >+say scalar(@$members) . " patrons to delete"; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{PrintError} = 0; >+ > for my $member (@$members) { > print "Trying to delete patron " . $member->{borrowernumber} . "... "; > eval { > C4::Members::MoveMemberToDeleted( $member->{borrowernumber} ) >- unless $dryrun; >+ if $confirm; > }; > if ($@) { >- say "Failed, I cannot move this patron ($@)"; >+ say "Failed, cannot move this patron ($@)"; > next; > } >- eval { C4::Members::DelMember( $member->{borrowernumber} ) unless $dryrun; }; >+ eval { C4::Members::DelMember( $member->{borrowernumber} ) if $confirm; }; > if ($@) { >- say "Failed, I cannot delete this patron ($@)"; >+ say "Failed, cannot delete this patron ($@)"; > next; > } > say "OK"; >@@ -67,7 +72,9 @@ delete_patrons - This script deletes patrons > > =head1 SYNOPSIS > >-delete_patrons.pl [-h -v] --not_borrowered_since=`date -d '-3 month' "+%Y-%m-%d"` --expired_before=`date -d '-3 month' "+%Y-%m-%d"` --category_code=CAT >+delete_patrons.pl [-h -v -c] --not_borrowered_since=2013-07-21 --expired_before=2013-07-21 --category_code=CAT >+ >+dates can be generated with `date -d '-3 month' "+%Y-%m-%d"` > > Options are cumulatives. > >@@ -91,9 +98,9 @@ Delete patrons with an account expired before this date. > > Delete patrons who have this category code. > >-=item B<--dry-run> >+=item B<-c|--confirm> > >-Dry run mode. To use with the verbose mode. >+Without this flag set, this script will do nothing. > > =item B<-v|--verbose> > >-- >1.7.2.5
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 10419
:
18677
|
18725
|
18743
|
18754
|
18990
|
19635
|
19651
|
20112
|
20113
|
20114
|
20115
|
20133
|
20134
|
20135
|
20136
|
20137
|
20138
|
20294
|
20295
|
20296
|
20297
|
21658
|
21765
|
21766
|
21773
|
21774
|
21780
|
21781
|
21782
|
21783
|
21784
|
21785
|
21786
|
21787