Bugzilla – Attachment 87589 Details for
Bug 22509
Add a script to generate MARC fields containing date formatted strings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22509: Add the --unless-exists option to the script
Bug-22509-Add-the---unless-exists-option-to-the-sc.patch (text/plain), 2.68 KB, created by
Hugo Agud
on 2019-04-09 08:35:20 UTC
(
hide
)
Description:
Bug 22509: Add the --unless-exists option to the script
Filename:
MIME Type:
Creator:
Hugo Agud
Created:
2019-04-09 08:35:20 UTC
Size:
2.68 KB
patch
obsolete
>From 84b0bf7829aa86a22402bca5675890a72324e594 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 4 Apr 2019 23:02:09 -0300 >Subject: [PATCH] Bug 22509: Add the --unless-exists option to the script > >It will avoid to create the fields several times if it is not needed. > >Signed-off-by: Hugo Agud <hagud@orex.es> >--- > misc/add_date_fields_to_marc_records.pl | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > >diff --git a/misc/add_date_fields_to_marc_records.pl b/misc/add_date_fields_to_marc_records.pl >index 03d3d66dc2..6368c36c58 100755 >--- a/misc/add_date_fields_to_marc_records.pl >+++ b/misc/add_date_fields_to_marc_records.pl >@@ -29,7 +29,7 @@ use MARC::Field; > use C4::Biblio; > use Koha::DateUtils qw( dt_from_string ); > >-my ( $verbose, $help, $confirm, $where, @fields ); >+my ( $verbose, $help, $confirm, $where, @fields, $unless_exists_field ); > my $dbh = C4::Context->dbh; > > GetOptions( >@@ -38,6 +38,7 @@ GetOptions( > 'confirm|c' => \$confirm, > 'where=s' => \$where, > 'field=s@' => \@fields, >+ 'unless-exists=s' => \$unless_exists_field, > ) || podusage(1); > > pod2usage(0) if $help; >@@ -51,7 +52,7 @@ for my $field (@fields) { > MARC::Field->new( $tag, '', '', $subfield => $dt->strftime($value) ); > } > >-say "Confirm flag not passed, running in dry-run mode..."; >+say "Confirm flag not passed, running in dry-run mode..." unless $confirm; > if ($verbose) { > say "The following MARC fields will be added:"; > say "\t" . $_->as_formatted for @fields_to_add; >@@ -66,6 +67,10 @@ while ( my ( $biblionumber, $frameworkcode ) = $sth->fetchrow_array ) { > my $marc_record = > C4::Biblio::GetMarcBiblio( { biblionumber => $biblionumber } ); > next unless $marc_record; >+ if ( $unless_exists_field ) { >+ my ( $tag, $subfield ) = split '\$', $unless_exists_field; >+ next if $marc_record->subfield($tag, $subfield); >+ } > $marc_record->append_fields(@fields_to_add); > if ($confirm) { > my $modified = >@@ -86,7 +91,7 @@ add_date_fields_to_marc_records.pl > > perl add_date_fields_to_marc_records.pl --help > >- perl add_date_fields_to_marc_records.pl --field='905$a=0/%Y' --field='905$a=1/%Y/%b-%m' --field='905$a=2/%Y/%b-%m/%d' --verbose --confirm >+ perl add_date_fields_to_marc_records.pl --field='905$a=0/%Y' --field='905$a=1/%Y/%b-%m' --field='905$a=2/%Y/%b-%m/%d' --unless-exists='905$a' --verbose --confirm > > =head1 DESCRIPTION > >@@ -123,6 +128,10 @@ For instance: > > 905$a=2/%Y/%b-%m/%d'will a a new field 905$a with the value '2/2019/Mar-03/13' if run on March 13th 2019 > >+=item B<--unless-exists> >+ >+Will only create the new fields if this field does not exist >+ > =back > > =cut >-- >2.11.0
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 22509
:
86586
|
87435
|
87588
|
87589
|
88532
|
88533
|
89546
|
89616
|
89626
|
89627
|
89680