Bugzilla – Attachment 42892 Details for
Bug 14292
Add --category and --skip-category options to longoverdue.pl to include or exclude borrower categories.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14292: QA Follow-up
Bug-14292-QA-Follow-up.patch (text/plain), 4.42 KB, created by
Barton Chittenden
on 2015-09-25 20:10:12 UTC
(
hide
)
Description:
Bug 14292: QA Follow-up
Filename:
MIME Type:
Creator:
Barton Chittenden
Created:
2015-09-25 20:10:12 UTC
Size:
4.42 KB
patch
obsolete
>From dce605afd14523a4d5609336cb1a800903badbc2 Mon Sep 17 00:00:00 2001 >From: Barton Chittenden <barton@bywatersolutions.com> >Date: Fri, 25 Sep 2015 13:04:55 -0700 >Subject: [PATCH] Bug 14292: QA Follow-up > >--- > misc/cronjobs/longoverdue.pl | 38 +++++++++++--------------------------- > 1 file changed, 11 insertions(+), 27 deletions(-) > >diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl >index 8bc1518..862aa75 100755 >--- a/misc/cronjobs/longoverdue.pl >+++ b/misc/cronjobs/longoverdue.pl >@@ -39,6 +39,7 @@ use C4::Circulation qw/LostItem/; > use Getopt::Long; > use C4::Log; > use Pod::Usage; >+use Koha::Borrowers; > > my $lost; # key=lost value, value=num days. > my ($charge, $verbose, $confirm, $quiet); >@@ -53,11 +54,11 @@ GetOptions( > 'lost=s%' => \$lost, > 'c|charge=s' => \$charge, > 'confirm' => \$confirm, >- 'verbose' => \$verbose, >+ 'v|verbose' => \$verbose, > 'quiet' => \$quiet, > 'maxdays=s' => \$endrange, > 'mark-returned' => \$mark_returned, >- 'help' => \$help, >+ 'h|help' => \$help, > 'man|manual' => \$man, > 'category=s' => $borrower_category, > 'skip-category=s' => $skip_borrower_category >@@ -77,7 +78,7 @@ if ( $help ) { > > longoverdue.pl [ --help | -h | --man ] > longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ] >- [ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGOERY ] ... >+ [ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGORY ] ... > [ --skip-category BORROWER_CATEGOERY ] ... [ --commit ] > > >@@ -184,8 +185,10 @@ if ( ! defined($lost) ) { > $lost->{$longoverdue_days} = $longoverdue_value; > } > else { >- pod2usage(1); >- die "ERROR: No --lost (-l) option defined"; >+ pod2usage( { >+ -exitval => 1, >+ -msg => q|ERROR: No --lost (-l) option defined|, >+ } ); > } > } > if ( ! defined($charge) ) { >@@ -223,23 +226,6 @@ sub longoverdue_sth { > return C4::Context->dbh->prepare($query); > } > >-# The following two functions can and should replaced by a call to >-# Koha::Database. >-sub borrower_categories_sth { >- my $query = "select distinct categorycode from categories"; >- return C4::Context->dbh->prepare($query); >-} >- >-sub defined_borrower_categories { >- my $sth = borrower_categories_sth(); >- my @categories = (); >- $sth->execute(); >- CATEGORY: while ( my $row = $sth->fetchrow_hashref ) { >- push @categories, uc( $row->{categorycode} ); >- } >- return @categories; >-} >- > # returns a hash of borrower category codes to test for long-overdue-ness. > # The key is the borrower category, upper case. The value is 1. This > # will make a fast look-up of valid borrower category codes. >@@ -248,7 +234,8 @@ sub get_borrower_categories { > > return () unless ( scalar @$borrower_category || scalar @$skip_borrower_category ); > >- my @categories = defined_borrower_categories(); >+ my $dbh = C4::Context->dbh; >+ my @categories = map { uc $_->[0] } @{ $dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) }; > if( @$borrower_category ) { > my %borcat = map { ( uc($_) => 1 ) } @$borrower_category; > @categories = grep { $borcat{$_} } @categories; >@@ -270,10 +257,7 @@ sub get_borrower_categories { > my %category_to_process = get_borrower_categories( $borrower_category, $skip_borrower_category ); > my $filter_borrower_categories = ( scalar @$borrower_category || scalar @$skip_borrower_category ); > >-#FIXME - Should add a 'system' user and get suitable userenv for it for logging, etc. >- > my $count; >-# my @ranges = map { > my @report; > my $total = 0; > my $i = 0; >@@ -295,7 +279,7 @@ foreach my $startrange (sort keys %$lost) { > $count=0; > ITEM: while (my $row=$sth_items->fetchrow_hashref) { > if( $filter_borrower_categories ) { >- my $category = uc Koha::Database->new()->schema->resultset('Borrower')->find( $row->{borrowernumber} )->get_column('categorycode'); >+ my $category = uc Koha::Borrowers->find( $row->{borrowernumber} )->categorycode(); > next ITEM unless ( $category_to_process{ $category } ); > } > printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose); >-- >1.7.10.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 14292
:
42125
|
42614
|
42892
|
43304
|
43305
|
43336
|
43337
|
43439
|
43489
|
43490
|
43491
|
43492
|
43493
|
43494
|
45293
|
45296