Bugzilla – Attachment 80746 Details for
Bug 21466
Data inconsistencies - koha fields linked to AV cat values must have a corresponding authorised value
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21466: Search for items.location inconsistencies
Bug-21466-Search-for-itemslocation-inconsistencies.patch (text/plain), 2.86 KB, created by
Jonathan Druart
on 2018-10-17 18:09:19 UTC
(
hide
)
Description:
Bug 21466: Search for items.location inconsistencies
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-10-17 18:09:19 UTC
Size:
2.86 KB
patch
obsolete
>From 941151db4c9ddd3b7f5a65e4f8f430bf50b67d5a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 17 Oct 2018 15:08:58 -0300 >Subject: [PATCH] Bug 21466: Search for items.location inconsistencies > >--- > .../maintenance/search_for_data_inconsistencies.pl | 51 +++++++++++++++++++++- > 1 file changed, 49 insertions(+), 2 deletions(-) > >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index 525d8c7609..99f4c99f4b 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -17,10 +17,12 @@ > > use Modern::Perl; > >-use Koha::Items; >+use Koha::AuthorisedValues; >+use Koha::Authorities; >+use Koha::BiblioFrameworks; > use Koha::Biblioitems; >+use Koha::Items; > use Koha::ItemTypes; >-use Koha::Authorities; > > { > my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); >@@ -107,6 +109,51 @@ use Koha::Authorities; > } > } > >+{ >+ my $frameworks = Koha::BiblioFrameworks->search; >+ my $invalid_locations_per_framework; >+ while ( my $framework = $frameworks->next ) { >+ my $avs = Koha::AuthorisedValues->search_by_koha_field( >+ { >+ frameworkcode => $framework->frameworkcode, >+ kohafield => 'items.location' >+ } >+ ); >+ my $items = Koha::Items->search( >+ { >+ location => >+ { -not_in => [ $avs->get_column('authorised_value') ] }, >+ 'biblio.frameworkcode' => $framework->frameworkcode >+ }, >+ { join => [ 'biblioitem', 'biblio' ] } >+ ); >+ if ( $items->count ) { >+ $invalid_locations_per_framework->{ $framework->frameworkcode } = >+ { items => $items, av_category => $avs->next->category, }; >+ } >+ } >+ if (%$invalid_locations_per_framework) { >+ new_section('Wrong value dor items.location'); >+ for my $frameworkcode ( keys %$invalid_locations_per_framework ) { >+ my $output; >+ my $items = >+ $invalid_locations_per_framework->{$frameworkcode}->{items}; >+ my $av_category = >+ $invalid_locations_per_framework->{$frameworkcode}->{av_category}; >+ while ( my $i = $items->next ) { >+ $output .= " {" . $i->itemnumber . " => " . $i->location . "}"; >+ } >+ new_item( >+ sprintf( >+ "The Framework *%s* is using the authorised value's category *%s*, " >+ . "but the following items.location do not have a value defined ({itemnumber => value }):\n%s", >+ $frameworkcode, $av_category, $output >+ ) >+ ); >+ } >+ } >+} >+ > sub new_section { > my ( $name ) = @_; > say "\n== $name =="; >-- >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 21466
:
80746
|
86118
|
95773
|
95774
|
98062
|
98063
|
98389