Bugzilla – Attachment 163259 Details for
Bug 36027
search_for_data_inconsistencies.pl - make each section optional
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36027 : (follow-up) Improvement : Add check option
Bug-36027--follow-up-Improvement--Add-check-option.patch (text/plain), 6.30 KB, created by
Phan Tung Bui
on 2024-03-15 17:48:07 UTC
(
hide
)
Description:
Bug 36027 : (follow-up) Improvement : Add check option
Filename:
MIME Type:
Creator:
Phan Tung Bui
Created:
2024-03-15 17:48:07 UTC
Size:
6.30 KB
patch
obsolete
>From e6dffbb228bae600a4cf7e28f94cfec8784e6968 Mon Sep 17 00:00:00 2001 >From: Phan Tung Bui <phan-tung.bui@inlibro.com> >Date: Fri, 15 Mar 2024 11:52:59 -0400 >Subject: [PATCH] Bug 36027 : (follow-up) Improvement : Add check option > >--- > .../search_for_data_inconsistencies.pl | 106 +++++++++++++----- > 1 file changed, 76 insertions(+), 30 deletions(-) > >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index d7c9344ccf..b4dee4d129 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -29,37 +29,77 @@ use C4::Biblio qw( GetMarcFromKohaField ); > use Getopt::Long; > use Pod::Usage; > >-my %options = ( >- 'branch' => 1, >- 'auth' => 1, >- 'status' => 1, >- 'framework' => 1, >- 'title' => 1, >- 'age' => 1, >- 'help' => 0, >+our %options = ( >+ 'check-branch' => 0, >+ 'check-auth' => 0, >+ 'check-status' => 0, >+ 'check-framework' => 0, >+ 'check-title' => 0, >+ 'check-age' => 0, >+ 'skip-branch' => 1, >+ 'skip-auth' => 1, >+ 'skip-status' => 1, >+ 'skip-framework' => 1, >+ 'skip-title' => 1, >+ 'skip-age' => 1, >+ 'help' => 0, > ); > > # Parse command line options > GetOptions( >- 'skip-branch' => sub { $options{'branch'} = 0 }, >- 'skip-auth' => sub { $options{'auth'} = 0 }, >- 'skip-status' => sub { $options{'status'} = 0 }, >- 'skip-framework' => sub { $options{'framework'} = 0 }, >- 'skip-title' => sub { $options{'title'} = 0 }, >- 'skip-age' => sub { $options{'age'} = 0 }, >- 'help' => sub { $options{'help'} = 1; }, >-) or pod2usage(2); # Print usage if invalid options are provided >+ 'check-branch' => sub { $options{'check-branch'} = 1 }, >+ 'check-auth' => sub { $options{'check-auth'} = 1 }, >+ 'check-status' => sub { $options{'check-status'} = 1 }, >+ 'check-framework' => sub { $options{'check-framework'} = 1 }, >+ 'check-title' => sub { $options{'check-title'} = 1 }, >+ 'check-age' => sub { $options{'check-age'} = 1 }, >+ 'skip-branch' => sub { $options{'skip-branch'} = 0 }, >+ 'skip-auth' => sub { $options{'skip-auth'} = 0 }, >+ 'skip-status' => sub { $options{'skip-status'} = 0 }, >+ 'skip-framework' => sub { $options{'skip-framework'} = 0 }, >+ 'skip-title' => sub { $options{'skip-title'} = 0 }, >+ 'skip-age' => sub { $options{'skip-age'} = 0 }, >+ 'help' => sub { $options{'help'} = 1; }, >+) or pod2usage(2); # Print usage if invalid options are provided >+ >+# Call handle_invalid_options subroutine if invalid options are provided >+Getopt::Long::Configure('pass_through'); >+GetOptions( >+ '<>' => sub { >+ my ($opt_name) = @_; >+ handle_invalid_options($opt_name); >+ } >+); > > # Print usage and exit if --help flag is provided > pod2usage(1) if $options{'help'}; > >-# Run checks based on options >-CheckItemsBranch() if $options{'branch'}; >-CheckItemsAuthHeader() if $options{'auth'}; >-CheckItemsStatus() if $options{'status'}; >-CheckItemsFramework() if $options{'framework'}; >-CheckItemsTitle() if $options{'title'}; >-CheckAgeForCategory() if $options{'age'}; >+# Run tests based on options >+set_skip_options(); >+CheckItemsBranch() if $options{'check-branch'} || $options{'skip-branch'}; >+CheckItemsAuthHeader() if $options{'check-auth'} || $options{'skip-auth'}; >+CheckItemsStatus() if $options{'check-status'} || $options{'skip-status'}; >+CheckItemsFramework() if $options{'check-framework'} || $options{'skip-framework'}; >+CheckItemsTitle() if $options{'check-title'} || $options{'skip-title'}; >+CheckAgeForCategory() if $options{'check-age'} || $options{'skip-age'}; >+ >+# Handle invalid options >+sub handle_invalid_options { >+ my ($opt_name) = @_; >+ print "Invalid option provided: $opt_name\n"; >+ pod2usage(2); >+} >+ >+# Set skip options based on check options >+sub set_skip_options { >+ my $has_check_option = grep { $options{$_} == 1 } grep { /^check-/ } keys %options; >+ if ($has_check_option) { >+ foreach my $key (keys %options) { >+ $options{$key} = 0 if $key =~ /^skip-/; >+ } >+ } >+ return %options; >+} > > sub CheckItemsBranch { > my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); >@@ -390,13 +430,19 @@ Catch data inconsistencies in Koha database: > > =head2 OPTIONS > >- --skip-branch Skip checking for items without home or holding library >- --skip-auth Skip checking for authority records with invalid authority type >- --skip-status Skip checking for bibliographic records and items without an item type or with an invalid item type >- --skip-framework Skip checking for invalid values in fields where the framework limits to an authorized value category >- --skip-title Skip checking for bibliographic records without a title >- --skip-age Skip checking for patrons with invalid age for category >- --help Print usage information >+ --check-branch Check for items without home or holding library >+ --check-auth Check for authority records with invalid authority type >+ --check-status Check for bibliographic records and items without an item type or with an invalid item type >+ --check-framework Check for invalid values in fields where the framework limits to an authorized value category >+ --check-title Check for bibliographic records without a title >+ --check-age Check for patrons with invalid age for category >+ --skip-branch Skip checking for items without home or holding library >+ --skip-auth Skip checking for authority records with invalid authority type >+ --skip-status Skip checking for bibliographic records and items without an item type or with an invalid item type >+ --skip-framework Skip checking for invalid values in fields where the framework limits to an authorized value category >+ --skip-title Skip checking for bibliographic records without a title >+ --skip-age Skip checking for patrons with invalid age for category >+ --help Print usage information > > Note: If no options are provided, all tests will be run. > >-- >2.34.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 36027
:
161852
|
161953
|
161954
|
162162
|
162349
|
162351
|
162540
|
162546
|
163259
|
163956
|
166117
|
167766
|
167787
|
168953
|
168954
|
169228
|
169229
|
170847
|
170848
|
170849
|
173269
|
173270
|
173271
|
173556