Bugzilla – Attachment 97783 Details for
Bug 22831
Add a maintenance script for checking DB vs index counts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22831: (RM follow-up) Code golf
Bug-22831-RM-follow-up-Code-golf.patch (text/plain), 2.42 KB, created by
Martin Renvoize (ashimema)
on 2020-01-23 10:24:06 UTC
(
hide
)
Description:
Bug 22831: (RM follow-up) Code golf
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-01-23 10:24:06 UTC
Size:
2.42 KB
patch
obsolete
>From 56fcf5a34d580026e0799baf07b537ac5bc43bb5 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 23 Jan 2020 10:20:31 +0000 >Subject: [PATCH] Bug 22831: (RM follow-up) Code golf > >Rather than performing a symmetric diff and then splitting the results >in a further loop this patch changes to logic to use two asymetric diffs >to get the results more directly. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > misc/maintenance/compare_es_to_db.pl | 24 +++++++----------------- > 1 file changed, 7 insertions(+), 17 deletions(-) > >diff --git a/misc/maintenance/compare_es_to_db.pl b/misc/maintenance/compare_es_to_db.pl >index 35d391b66b..ee5473b646 100644 >--- a/misc/maintenance/compare_es_to_db.pl >+++ b/misc/maintenance/compare_es_to_db.pl >@@ -30,7 +30,7 @@ B<compare_es_to_db.pl> > =cut > > use Modern::Perl; >-use Array::Utils qw( array_diff ); >+use Array::Utils qw( array_minus ); > > use C4::Context; > >@@ -76,29 +76,18 @@ foreach my $index ( ('biblios','authorities') ){ > push @es_ids, $doc->{_id}; > $i++; > } >- print "\nComparing arrays, this may take a while\n"; >- >- # And compare the arrays >- # array_diff returns only a list of values which are not common to both arrays >- my @diff = array_diff(@db_records, @es_ids ); >- >- print "All records match\n" unless @diff; > > # Fetch values for providing record links > my $es_params = $searcher->get_elasticsearch_params; > my $es_base = "$es_params->{nodes}[0]/$es_params->{index_name}"; > my $opac_base = C4::Context->preference('OPACBaseURL'); > >+ print "\nComparing arrays, this may take a while\n"; >+ >+ my @koha_problems = sort { $a <=> $b } array_minus(@db_records, @es_ids); >+ my @es_problems = sort { $a <=> $b } array_minus(@es_ids, @db_records); > >- my @koha_problems; >- my @es_problems; >- foreach my $problem ( sort { $a <=> $b } @diff){ >- if ( (grep /^$problem$/, @db_records) ){ >- push @koha_problems, $problem; >- } else { >- push @es_problems, $problem; >- } >- } >+ print "All records match\n" unless ( @koha_problems || @es_problems ); > > if ( @koha_problems ){ > print "=================\n"; >@@ -113,6 +102,7 @@ foreach my $index ( ('biblios','authorities') ){ > } > } > } >+ > if ( @es_problems ){ > print "=================\n"; > print "Records that exist in ES but not in Koha\n"; >-- >2.20.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 22831
:
89233
|
95077
|
95105
|
95109
|
95110
|
95154
|
95155
|
95156
|
95157
|
95176
|
96804
|
96805
|
96806
|
97339
|
97340
|
97341
| 97783