Bugzilla – Attachment 45607 Details for
Bug 15336
Script for merging vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15336 - Fix QA comments
Bug-15336---Fix-QA-comments.patch (text/plain), 4.67 KB, created by
Alex Arnaud
on 2015-12-11 12:59:55 UTC
(
hide
)
Description:
Bug 15336 - Fix QA comments
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2015-12-11 12:59:55 UTC
Size:
4.67 KB
patch
obsolete
>From 150a0af9d41fe1b35ae432a3b847bb68a0f46018 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Fri, 11 Dec 2015 13:59:26 +0100 >Subject: [PATCH] Bug 15336 - Fix QA comments > >--- > misc/migration_tools/merge_booksellers.pl | 104 +++++++++++++++++++++-------- > 1 file changed, 77 insertions(+), 27 deletions(-) > >diff --git a/misc/migration_tools/merge_booksellers.pl b/misc/migration_tools/merge_booksellers.pl >index a9f6a5d..9ec664e 100644 >--- a/misc/migration_tools/merge_booksellers.pl >+++ b/misc/migration_tools/merge_booksellers.pl >@@ -1,7 +1,23 @@ > #!/usr/bin/perl >-# Script that merge source bookseller (-f) into target bookseller (-t). > >-use strict; >+# Copyright 2015 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; > > use Koha::Acquisition::Bookseller; > use C4::Bookseller qw( DelBookseller ); >@@ -9,19 +25,23 @@ use C4::Acquisition; > use C4::Contract; > > use Getopt::Long; >+use Pod::Usage; > > my ($help, $verbose, $mergefrom, $mergeto, $confirm); > GetOptions( >- 'h' => \$help, >- 'v' => \$verbose, >- 'f:s' => \$mergefrom, >- 't:s' => \$mergeto, >- 'c' => \$confirm, >-); >+ 'help|h' => \$help, >+ 'verbose|v' => \$verbose, >+ 'from|f:s' => \$mergefrom, >+ 'to|t:s' => \$mergeto, >+ 'confirm|c' => \$confirm, >+) || pod2usage(1); > > if ($help || !$mergefrom || !$mergeto) { >- print_usage(); >- die; >+ pod2usage(1); >+} >+ >+if ($mergefrom eq $mergeto) { >+ pod2usage('Source and target booksellers should be different.'); > } > > my $from_bookseller = Koha::Acquisition::Bookseller->fetch({id => $mergefrom}); >@@ -31,14 +51,15 @@ my $to_bookseller = Koha::Acquisition::Bookseller->fetch({id => $mergeto}); > die "Unknown bookseller id ($mergeto)" unless $to_bookseller; > > my $report; >-foreach (qw(Aqbasketgroup Aqbasket Aqcontract Aqcontact Aqinvoice)) { >- my $rs = Koha::Database->new()->schema->resultset($_); >- $rs = $rs->search({booksellerid => $mergefrom }); >+foreach my $entity (qw(Aqbasketgroup Aqbasket Aqcontract Aqcontact Aqinvoice Deleteditem Item Subscription)) { >+ my $rs = Koha::Database->new()->schema->resultset($entity); >+ my $foreign_key = $entity eq 'Subscription' ? 'aqbooksellerid' : 'booksellerid'; >+ $rs = $rs->search({$foreign_key => $mergefrom }); > while (my $e = $rs->next) { > $e->set_column('booksellerid', $mergeto); >- print "$_ n° " . $e->id() . " merged into bookseller n° $mergeto\n" if $verbose; >+ print "$entity n° " . $e->id() . " merged into bookseller n° $mergeto\n" if $verbose; > $e->update() if $confirm; >- $report->{$_}++; >+ $report->{$entity}++; > } > } > >@@ -48,18 +69,6 @@ print "\n" if $verbose; > print_report($report); > print "Nothing done (test only). Use confirm option to commit changes in database\n" unless $confirm; > >-sub print_usage { >-print <<EOF >- Script to merge a bookselle into another >- parameters : >- \th : this help screen >- \tf : the bookseller id to merge. >- \tt : the bookseller id where to merge >- \tc : Perform changes in database. >-EOF >-; >-} >- > sub print_report { > my $report = shift; > >@@ -67,3 +76,44 @@ sub print_report { > print "$entity merged: $report->{$entity}\n"; > } > } >+ >+ >+=head1 NAME >+ >+merge source bookseller (-f) into target bookseller (-t) >+ >+=head1 SYNOPSIS >+ >+merge_booksellers.pl [-h|--help] [-v|--verbose] [-c|--confirm] --from=booksellerid --to=booksellerid >+ >+=head1 OPTIONS >+ >+=over >+ >+=item B<-h|--help> >+ >+Print a brief help message. >+ >+=item B<--verbose> >+ >+ --verbose Show more information on what is done. >+ >+=item B<--confirm> >+ >+ --confirm Commit the changes in database. Running without this >+ parameter is like testing. It is recommanded to run without >+ --confirm first to be sure of the changes. >+ >+=item B<--from> >+ >+ --from=<booksellerid> The source bookseller identifier that will be merged in >+ target bookseller. >+ >+=item B<--to> >+ >+ --to=<booksellerid> The target bookseller identifier in which merge >+ source bookseller. >+ >+=back >+ >+=cut >-- >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 15336
:
45521
|
45530
|
45607
|
45777
|
49313
|
61070
|
61071
|
61104
|
61105
|
61108
|
61109
|
64595
|
66765
|
66766
|
66767
|
68676
|
72023
|
72734
|
73078