Bug 35653: Log import_patrons.pl info to action logs
To test: 1. APPLY PATCH 2. Create a CSV file with a few lines that contain at least firstname, surname, cardnumber 3. Turn on "CronjobLog". 4. Run the import patron script. I did this: perl /kohadevbox/koha/misc/import_patrons.pl --file 'test1.csv' --matchpoint cardnumber -c 5. Check the action logs for cronjobs. 6. You should see info. about the import patron script. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
353f510c14
commit
3198621787
1 changed files with 16 additions and 2 deletions
|
@ -24,6 +24,7 @@ use Pod::Usage qw( pod2usage );
|
|||
|
||||
use Koha::Script;
|
||||
use Koha::Patrons::Import;
|
||||
use C4::Log qw( cronlogaction );
|
||||
my $Import = Koha::Patrons::Import->new();
|
||||
|
||||
my $csv_file;
|
||||
|
@ -40,6 +41,9 @@ my @preserve_fields;
|
|||
my $update_dateexpiry;
|
||||
my $update_dateexpiry_from_today;
|
||||
|
||||
|
||||
my $command_line_options = join(" ",@ARGV);
|
||||
|
||||
GetOptions(
|
||||
'c|confirm' => \$confirm,
|
||||
'f|file=s' => \$csv_file,
|
||||
|
@ -60,7 +64,11 @@ pod2usage(1) if $help;
|
|||
pod2usage(q|--file is required|) unless $csv_file;
|
||||
pod2usage(q|--matchpoint is required|) unless $matchpoint;
|
||||
|
||||
warn "Running in dry-run mode, provide --confirm to apply the changes\n" unless $confirm;
|
||||
if ( $confirm ) {
|
||||
cronlogaction({ action => 'Run', info => $command_line_options })
|
||||
} else {
|
||||
warn "Running in dry-run mode, provide --confirm to apply the changes\n";
|
||||
}
|
||||
|
||||
my $handle;
|
||||
open( $handle, "<", $csv_file ) or die $!;
|
||||
|
@ -87,9 +95,9 @@ my $imported = $return->{imported};
|
|||
my $overwritten = $return->{overwritten};
|
||||
my $alreadyindb = $return->{already_in_db};
|
||||
my $invalid = $return->{invalid};
|
||||
my $total = $imported + $alreadyindb + $invalid + $overwritten;
|
||||
|
||||
if ($verbose) {
|
||||
my $total = $imported + $alreadyindb + $invalid + $overwritten;
|
||||
say q{};
|
||||
say "Import complete:";
|
||||
say "Imported: $imported";
|
||||
|
@ -110,6 +118,12 @@ if ($verbose > 2 ) {
|
|||
say Data::Dumper::Dumper( $feedback );
|
||||
}
|
||||
|
||||
my $info = "Import complete. " . "Imported: " . $imported . " Overwritten: " . $overwritten . " Skipped: " . $alreadyindb . " Invalid: " . $invalid . " Total: " . $total;
|
||||
|
||||
if ( $confirm ) {
|
||||
cronlogaction({ action => 'End', info => $info });
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
||||
import_patrons.pl - CLI script to import patrons data into Koha
|
||||
|
|
Loading…
Reference in a new issue