Bugzilla – Attachment 57807 Details for
Bug 17693
Add option to export deleted bibs in export_records.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add option to export deleted bibs in export_records.pl
Add-option-to-export-deleted-bibs-in-exportrecords.patch (text/plain), 5.02 KB, created by
Theodoros Theodoropoulos
on 2016-11-29 14:18:54 UTC
(
hide
)
Description:
Add option to export deleted bibs in export_records.pl
Filename:
MIME Type:
Creator:
Theodoros Theodoropoulos
Created:
2016-11-29 14:18:54 UTC
Size:
5.02 KB
patch
obsolete
>From fbfb75157ede399a27ba3511a47e5345622cd6e5 Mon Sep 17 00:00:00 2001 >From: sbujam <sbujam@users.noreply.github.com> >Date: Tue, 29 Nov 2016 16:05:20 +0200 >Subject: [PATCH] Add option to export deleted bibs in export_records.pl > >This commit adds an additional option to the export_records.pl >script, so that users will be able to get a line-seperated >list of biblionumbers with records deleted (optionally after >a specified date). > >Test plan: >1/ Apply patch >2/ delete one or more marc records from Koha >3/ from within the ./misc/ folder run: > export_records.pl --deleted_bibs --record-type='bibs' > You should get a Koha.mrc file with the deleted biblionumbers > (one per line). >4/ you may also use '--date' option like so: > export_records.pl --deleted_bibs --record-type='bibs' --date="YYYY-MM-DD" > This way you should get a filtered list of biblionumbers that were deleted > AFTER the specified date. > >https://bugs.koha-community.org/show_bug.cgi?id=17693 >--- > misc/export_records.pl | 34 +++++++++++++++++++++++++++++++--- > 1 file changed, 31 insertions(+), 3 deletions(-) > >diff --git a/misc/export_records.pl b/misc/export_records.pl >index 2bb553d..8e9d717 100755 >--- a/misc/export_records.pl >+++ b/misc/export_records.pl >@@ -32,13 +32,14 @@ use Koha::CsvProfiles; > use Koha::Exporter::Record; > use Koha::DateUtils qw( dt_from_string output_pref ); > >-my ( $output_format, $timestamp, $dont_export_items, $csv_profile_id, $deleted_barcodes, $clean, $filename, $record_type, $id_list_file, $starting_authid, $ending_authid, $authtype, $starting_biblionumber, $ending_biblionumber, $itemtype, $starting_callnumber, $ending_callnumber, $start_accession, $end_accession, $help ); >+my ( $output_format, $timestamp, $dont_export_items, $csv_profile_id, $deleted_barcodes, $deleted_bibs, $clean, $filename, $record_type, $id_list_file, $starting_authid, $ending_authid, $authtype, $starting_biblionumber, $ending_biblionumber, $itemtype, $starting_callnumber, $ending_callnumber, $start_accession, $end_accession, $help ); > GetOptions( > 'format=s' => \$output_format, > 'date=s' => \$timestamp, > 'dont_export_items' => \$dont_export_items, > 'csv_profile_id=s' => \$csv_profile_id, > 'deleted_barcodes' => \$deleted_barcodes, >+ 'deleted_bibs' => \$deleted_bibs, > 'clean' => \$clean, > 'filename=s' => \$filename, > 'record-type=s' => \$record_type, >@@ -84,6 +85,10 @@ if ( $deleted_barcodes and $record_type ne 'bibs' ) { > pod2usage(q|--deleted_barcodes can only be used with biblios|); > } > >+if ( $deleted_bibs and $record_type ne 'bibs' ) { >+ pod2usage(q|--deleted_bibs can only be used with biblios|); >+} >+ > $start_accession = dt_from_string( $start_accession ) if $start_accession; > $end_accession = dt_from_string( $end_accession ) if $end_accession; > >@@ -98,6 +103,23 @@ my @record_ids; > $timestamp = ($timestamp) ? output_pref({ dt => dt_from_string($timestamp), dateformat => 'iso', dateonly => 0, }): ''; > > if ( $record_type eq 'bibs' ) { >+ if ($deleted_bibs) { >+ my $q = " >+ SELECT DISTINCT biblionumber >+ FROM deletedbiblio"; >+ if ( $timestamp ) { >+ $q .= " WHERE deletedbiblio.timestamp >= '$timestamp' "; >+ } >+ #print "Debug: $q\n"; >+ my $sth = $dbh->prepare($q); >+ $sth->execute(); >+ while ( my $row = $sth->fetchrow_array ) { >+ say $row; >+ #print "$row\n"; >+ } >+ exit; >+ } >+ > if ( $timestamp ) { > push @record_ids, $_->{biblionumber} for @{ > $dbh->selectall_arrayref(q| ( >@@ -217,7 +239,7 @@ export records - This script exports record (biblios or authorities) > > =head1 SYNOPSIS > >-export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--clean] [--id_list_file=PATH] --filename=outputfile >+export_records.pl [-h|--help] [--format=format] [--date=datetime] [--record-type=TYPE] [--dont_export_items] [--deleted_barcodes] [--deleted_bibs] [--clean] [--id_list_file=PATH] --filename=outputfile > > =head1 OPTIONS > >@@ -236,7 +258,7 @@ Print a brief help message. > --date=DATETIME DATETIME should be entered as the 'dateformat' syspref is > set (dd/mm/yyyy[ hh:mm:ss] for metric, yyyy-mm-dd[ hh:mm:ss] for iso, > mm/dd/yyyy[ hh:mm:ss] for us) records exported are the ones that >- have been modified since DATETIME. >+ have been modified or deleted since DATETIME. > > =item B<--record-type> > >@@ -258,6 +280,12 @@ Print a brief help message. > is produced (or from all deleted items if no date is > specified). Used only if TYPE is 'bibs'. > >+=item B<--deleted_bibs> >+ >+ --deleted_bibs If used, a list of deleted biblionumbers since DATE >+ is produced (or from all deleted bibs if no date is >+ specified). Used only if TYPE is 'bibs'. >+ > =item B<--clean> > > --clean removes NSE/NSB. >-- >1.9.1
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 17693
: 57807