Bugzilla – Attachment 123497 Details for
Bug 22690
Merging records with many items too slow (Elasticsearch)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22690: (QA follow-up) Fix indexing for Items sets
Bug-22690-QA-follow-up-Fix-indexing-for-Items-sets.patch (text/plain), 5.14 KB, created by
Martin Renvoize
on 2021-08-05 13:29:44 UTC
(
hide
)
Description:
Bug 22690: (QA follow-up) Fix indexing for Items sets
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2021-08-05 13:29:44 UTC
Size:
5.14 KB
patch
obsolete
>From 591ca4ab00e4a36f33df1892509c98d2474cbc6f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 5 Aug 2021 14:19:55 +0100 >Subject: [PATCH] Bug 22690: (QA follow-up) Fix indexing for Items sets > >This patch adds tests and handling for calling move_to_biblio on a >Koha::Items set that contains items from more than one source biblio. > >Test plan >1/ Inspect the changes to t/db_dependent/Koha/SearchEngine/Indexer.t >2/ Run t/db_dependent/Koha/SearchEngine/Indexer.t and confirm it passes >--- > Koha/Items.pm | 11 +++++++---- > t/db_dependent/Koha/SearchEngine/Indexer.t | 22 ++++++++++++++-------- > 2 files changed, 21 insertions(+), 12 deletions(-) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 4d3de57056..193e6e58d2 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -121,12 +121,15 @@ Move items to a given biblio. > sub move_to_biblio { > my ( $self, $to_biblio ) = @_; > >- while (my $item = $self->next()) { >- $item->move_to_biblio($to_biblio, { skip_record_index => 1 }); >+ my $biblionumbers = { $to_biblio->biblionumber => 1 }; >+ while ( my $item = $self->next() ) { >+ $biblionumbers->{ $item->biblionumber } = 1; >+ $item->move_to_biblio( $to_biblio, { skip_record_index => 1 } ); > } > my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >- $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" ); >- $indexer->index_records( $to_biblio->biblionumber, "specialUpdate", "biblioserver" ); >+ for my $biblionumber ( keys %{$biblionumbers} ) { >+ $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); >+ } > } > > >diff --git a/t/db_dependent/Koha/SearchEngine/Indexer.t b/t/db_dependent/Koha/SearchEngine/Indexer.t >index 22ff468571..610a738060 100755 >--- a/t/db_dependent/Koha/SearchEngine/Indexer.t >+++ b/t/db_dependent/Koha/SearchEngine/Indexer.t >@@ -61,7 +61,7 @@ subtest 'Test indexer object creation' => sub { > }; > > subtest 'Test indexer calls' => sub { >- plan tests => 46; >+ plan tests => 48; > > my @engines = ('Zebra'); > eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; >@@ -105,11 +105,12 @@ subtest 'Test indexer calls' => sub { > > my $biblio; > my $biblio2; >+ my $biblio3; > warnings_are{ > $biblio = $builder->build_sample_biblio(); > $biblio2 = $builder->build_sample_biblio(); >- } [$engine,'C4::Biblio',$engine,'C4::Biblio'], "index_records is called for $engine when adding a biblio (ModBiblioMarc)"; >- >+ $biblio3 = $builder->build_sample_biblio(); >+ } [$engine,'C4::Biblio',$engine,'C4::Biblio',$engine,'C4::Biblio'], "index_records is called for $engine when adding a biblio (ModBiblioMarc)"; > > my $item; > my $item2; >@@ -132,8 +133,8 @@ subtest 'Test indexer calls' => sub { > }); > $item3 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); > $item4 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >- $item5 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >- $item6 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >+ $item5 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber}); >+ $item6 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber}); > } [$engine,"Koha::Item", > $engine,"Koha::Item", > $engine,"Koha::Item", >@@ -185,7 +186,12 @@ subtest 'Test indexer calls' => sub { > > warnings_are{ > $biblio->items->move_to_biblio($biblio2); >- } [$engine,"Koha::Biblio",$engine,"Koha::Biblio"], "index_records is called for both biblios for $engine when adopting items (Biblio->items->move_to_biblio(Biblio)"; >+ } [$engine,"Koha::Items",$engine,"Koha::Items"], "index_records is called for from and to biblios for $engine when adopting items (Biblio->items->move_to_biblio(Biblio)"; >+ >+ my $items = Koha::Items->search({ itemnumber => [ $item2->itemnumber, $item5->itemnumber, $item6->itemnumber ] }); >+ warnings_are{ >+ $items->move_to_biblio($biblio); >+ } [$engine,"Koha::Items",$engine,"Koha::Items",$engine,"Koha::Items"], "index_records is called for all from and to biblios for $engine when adopting items (Items->move_to_biblio(Biblio)"; > > $builder->build({ > source => 'Issue', >@@ -231,10 +237,10 @@ subtest 'Test indexer calls' => sub { > } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed"; > > warnings_are{ >- DelBiblio( $biblio->biblionumber ); >+ DelBiblio( $biblio3->biblionumber ); > } [$engine, "C4::Biblio"], "index_records is called for $engine when calling DelBiblio"; > warnings_are{ >- DelBiblio( $biblio->biblionumber, { skip_record_index =>1 }); >+ DelBiblio( $biblio3->biblionumber, { skip_record_index =>1 }); > } undef, "index_records is not called for $engine when calling DelBiblio if skip_record_index passed"; > > } >-- >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 22690
:
90061
|
90115
|
90116
|
92828
|
94505
|
97696
|
98143
|
98210
|
98211
|
99376
|
99379
|
100316
|
104796
|
104797
|
104871
|
105445
|
106144
|
108777
|
109694
|
110991
|
110994
|
111196
|
111207
|
111236
|
111237
|
112100
|
112184
|
112567
|
112569
|
112754
|
113308
|
113309
|
113941
|
113942
|
113967
|
113968
|
118226
|
118227
|
118229
|
118231
|
118391
|
119433
|
119434
|
120820
|
120821
|
120852
|
120853
|
121389
|
121392
|
121474
|
121516
|
121517
|
121518
|
121519
|
121520
|
122846
|
122847
|
122848
|
122849
|
122850
|
122886
|
122887
|
122888
|
122889
|
122890
|
122936
|
122938
|
122939
|
123029
|
123030
|
123031
|
123032
|
123033
|
123034
|
123035
|
123036
|
123037
|
123038
|
123039
|
123040
|
123041
|
123042
|
123044
|
123062
|
123481
|
123482
|
123483
|
123484
|
123485
|
123486
|
123487
|
123488
|
123489
|
123490
|
123491
|
123492
|
123493
|
123494
|
123495
|
123496
| 123497 |
124176
|
124188
|
124257