Bugzilla – Attachment 164817 Details for
Bug 35836
search_for_data_inconsistencies.pl - Search for loops in dependencies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35836: search_for_data_inconsistencies.pl - Search for loops in dependencies
Bug-35836-searchfordatainconsistenciespl---Search-.patch (text/plain), 4.65 KB, created by
Philip Orr
on 2024-04-12 09:09:25 UTC
(
hide
)
Description:
Bug 35836: search_for_data_inconsistencies.pl - Search for loops in dependencies
Filename:
MIME Type:
Creator:
Philip Orr
Created:
2024-04-12 09:09:25 UTC
Size:
4.65 KB
patch
obsolete
>From 830e2ea9ffc5c431371cec029838dec645ce17f4 Mon Sep 17 00:00:00 2001 >From: Matthias Le Gac <matthias.le-gac@inlibro.com> >Date: Thu, 22 Feb 2024 14:26:24 -0500 >Subject: [PATCH] Bug 35836: search_for_data_inconsistencies.pl - Search for > loops in dependencies > >Signed-off-by: Philip Orr <philip.orr@lmscloud.de> >--- > .../search_for_data_inconsistencies.pl | 91 +++++++++++++++++++ > 1 file changed, 91 insertions(+) > >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index ddc6b457dd..cf2fb065a3 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -326,6 +326,97 @@ use C4::Biblio qw( GetMarcFromKohaField ); > } > } > >+{ >+ my @loop_borrowers_relationships; >+ my $relationships = Koha::Patron::Relationships->search(); >+ my @patrons_guarantors = Koha::Patron::Relationships::guarantors($relationships)->as_list; >+ my @patrons_guarantees = Koha::Patron::Relationships::guarantees($relationships)->as_list; >+ >+ foreach my $patron_guarantor (@patrons_guarantors) { >+ foreach my $patron_guarantee (@patrons_guarantees) { >+ if ( $patron_guarantor->borrowernumber == $patron_guarantee->borrowernumber ) { >+ >+ my $guarantor_id; >+ my $guarantee_id; >+ my $size_list; >+ my $tmp_garantor_id = $patron_guarantor->borrowernumber; >+ my @guarantor_ids; >+ >+ do { >+ my @relationship_for_go = Koha::Patron::Relationships->search( >+ { >+ -or => [ >+ 'guarantor_id' => { '=', $tmp_garantor_id }, >+ ] >+ }, >+ )->as_list; >+ $size_list = scalar @relationship_for_go; >+ >+ foreach my $relation (@relationship_for_go) { >+ $guarantor_id = $relation->guarantor_id; >+ unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { >+ push @guarantor_ids, $guarantor_id; >+ } >+ $guarantee_id = $relation->guarantee_id; >+ >+ my @relationship_for_go = Koha::Patron::Relationships->search( >+ { >+ -or => [ >+ 'guarantor_id' => { '=', $guarantee_id }, >+ ] >+ }, >+ )->as_list; >+ $size_list = scalar @relationship_for_go; >+ >+ if ( $patron_guarantor->borrowernumber == $guarantee_id ) { >+ last; >+ } >+ >+ foreach my $relation (@relationship_for_go) { >+ $guarantor_id = $relation->guarantor_id; >+ unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { >+ push @guarantor_ids, $guarantor_id; >+ } >+ $guarantee_id = $relation->guarantee_id; >+ >+ if ( $patron_guarantor->borrowernumber == $guarantee_id ) { >+ last; >+ } >+ } >+ if ( $patron_guarantor->borrowernumber == $guarantee_id ) { >+ last; >+ } >+ } >+ >+ $tmp_garantor_id = $guarantee_id; >+ } while ( $patron_guarantor->borrowernumber != $guarantee_id && $size_list > 0 ); >+ >+ if ( $patron_guarantor->borrowernumber == $guarantee_id ) { >+ unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) } >+ @loop_borrowers_relationships ) >+ { >+ push @loop_borrowers_relationships, \@guarantor_ids; >+ } >+ } >+ } >+ } >+ } >+ >+ if ( scalar @loop_borrowers_relationships > 0 ) { >+ new_section("The list of guarantors who are also guarantee."); >+ my $count = 0; >+ foreach my $table (@loop_borrowers_relationships) { >+ $count++; >+ print "Loop $count, borrowers id : "; >+ foreach my $borrower_id (@$table) { >+ print "$borrower_id | "; >+ } >+ print "\n"; >+ } >+ new_hint("Relationships that form guarantor loops must be deleted"); >+ } >+} >+ > sub new_section { > my ( $name ) = @_; > say "\n== $name =="; >-- >2.30.2
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 35836
:
161249
|
161307
|
161351
|
161836
|
161837
|
161838
|
161839
|
161840
|
161841
|
161842
|
161843
|
161844
|
162284
|
162341
|
162344
|
163368
|
164817
|
164818
|
166751
|
166752
|
166825