Bugzilla – Attachment 61173 Details for
Bug 16187
Add a script to cancel unfilled holds after a specified number of days
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16187 - (QA followup) Tidy, add confirm, minor changes
Bug-16187---QA-followup-Tidy-add-confirm-minor-cha.patch (text/plain), 4.33 KB, created by
Nick Clemens (kidclamp)
on 2017-03-16 14:40:52 UTC
(
hide
)
Description:
Bug 16187 - (QA followup) Tidy, add confirm, minor changes
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-03-16 14:40:52 UTC
Size:
4.33 KB
patch
obsolete
>From a5900a1c719febc8e4bed6c8e359a58c6377892d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 16 Mar 2017 10:39:37 -0400 >Subject: [PATCH] Bug 16187 - (QA followup) Tidy, add confirm, minor changes > >--- > misc/cronjobs/holds/cancel_waiting_holds.pl | 72 +++++++++++++++++++---------- > 1 file changed, 47 insertions(+), 25 deletions(-) > >diff --git a/misc/cronjobs/holds/cancel_waiting_holds.pl b/misc/cronjobs/holds/cancel_waiting_holds.pl >index 0db1817..1d6bc68 100755 >--- a/misc/cronjobs/holds/cancel_waiting_holds.pl >+++ b/misc/cronjobs/holds/cancel_waiting_holds.pl >@@ -85,56 +85,78 @@ my $help = 0; > my $days; > my @branchcodes; > my $use_calendar = 0; >-my $verbose = 0; >+my $verbose = 0; >+my $confirm = 0; > > GetOptions( >- 'help|?' => \$help, >- 'days=s' => \$days, >- 'library=s' => \@branchcodes, >- 'holidays' => \$use_calendar, >- 'v' => \$verbose >+ 'help|?' => \$help, >+ 'days=s' => \$days, >+ 'library=s' => \@branchcodes, >+ 'holidays' => \$use_calendar, >+ 'v' => \$verbose, >+ 'confirm' => \$confirm, > ) or pod2usage(1); > pod2usage(1) if $help; > >-unless (defined $days) { >- pod2usage({ >+unless ( defined $days ) { >+ pod2usage( >+ { > -exitval => 1, >- -msg => qq{\nError: You must specify a value for days waiting to cancel holds.\n}, >- }); >+ -msg => >+qq{\nError: You must specify a value for days waiting to cancel holds.\n}, >+ } >+ ); > } >-$verbose and warn "Will cancel unfilled holds placed $days or more days ago\n"; >+warn "Running in test mode, no actions will be taken" unless ($confirm); >+ >+$verbose and warn "Looking for unfilled holds placed $days or more days ago\n"; > >-unless (scalar @branchcodes > 0 ) { >- my $branches = Koha::Libraries->search( {} , {columns => 'branchcode' } ); >+unless ( scalar @branchcodes > 0 ) { >+ my $branches = Koha::Libraries->search->get_column('branchcode'); > while ( my $branch = $branches->next ) { > push @branchcodes, $branch->branchcode; > } > } >-$verbose and warn "Running for branch(es): ".join("|",@branchcodes)."\n"; >+$verbose and warn "Running for branch(es): " . join( "|", @branchcodes ) . "\n"; > >-foreach my $branch (@branchcodes){ >+foreach my $branch (@branchcodes) { > >- my $holds = Koha::Holds->search( { found => undef , branchcode => $branch } ); >+ my $holds = >+ Koha::Holds->search( { found => undef, branchcode => $branch } ); > >- while ( my $hold = $holds->next ){ >+ while ( my $hold = $holds->next ) { > > my $days_waiting; >- my $today = DateTime->now(time_zone => C4::Context->tz ); >+ my $today = dt_from_string(); > >- if ( $use_calendar ) { >+ if ($use_calendar) { > my $calendar = Koha::Calendar->new( branchcode => $branch ); >- $days_waiting = $calendar->days_between( dt_from_string( $hold->reservedate ), $today ); >+ $days_waiting = >+ $calendar->days_between( dt_from_string( $hold->reservedate ), >+ $today ); > } > else { >- $days_waiting = $today->delta_days( dt_from_string( $hold->reservedate ) ); >+ $days_waiting = >+ $today->delta_days( dt_from_string( $hold->reservedate ) ); > } >- $days_waiting = $days_waiting->in_units( 'days' ); >+ $days_waiting = $days_waiting->in_units('days'); > >- $verbose and warn "Hold #".$hold->reserve_id." has been waiting $days_waiting day(s)\n"; >+ $verbose >+ and warn "Hold #" >+ . $hold->reserve_id >+ . " has been waiting $days_waiting day(s)\n"; > > if ( $days_waiting >= $days ) { >- $verbose and warn "Cancelling reserve_id: ".$hold->reserve_id." for borrower: ".$hold->borrowernumber." on biblio: ".$hold->biblionumber."\n"; >- CancelReserve( {reserve_id => $hold->reserve_id } ); >+ my $action = $confirm ? "Cancelling " : "Would have cancelled "; >+ $verbose >+ and warn $action >+ . "reserve_id: " >+ . $hold->reserve_id >+ . " for borrower: " >+ . $hold->borrowernumber >+ . " on biblio: " >+ . $hold->biblionumber . "\n"; >+ CancelReserve( { reserve_id => $hold->reserve_id } ) if $confirm; > } > > } >-- >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 16187
:
53397
|
56275
|
61173
|
61951
|
64924
|
68289
|
68290
|
68309
|
68310
|
68311