Bugzilla – Attachment 123495 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) Add TrackedLink classes and use them
Bug-22690-QA-follow-up-Add-TrackedLink-classes-and.patch (text/plain), 6.38 KB, created by
Martin Renvoize (ashimema)
on 2021-08-05 13:29:33 UTC
(
hide
)
Description:
Bug 22690: (QA follow-up) Add TrackedLink classes and use them
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-08-05 13:29:33 UTC
Size:
6.38 KB
patch
obsolete
>From d86fa0b7cebbedd9a7c6b5be348c212706ebbedc Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 22 Jul 2021 11:40:20 +0100 >Subject: [PATCH] Bug 22690: (QA follow-up) Add TrackedLink classes and use > them > >This patch adds Koha::TrackedLink(s) classes based on Koha::Object(s) >and then adds the relationship accessor to Koha::Item and uses it within >the move_to_biblio method. > >Tests for new relationship also added to t/db_dependent/Koha/Item.t >--- > Koha/Item.pm | 22 ++++++++++++++--- > Koha/TrackedLink.pm | 43 +++++++++++++++++++++++++++++++++ > Koha/TrackedLinks.pm | 49 ++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Item.t | 22 ++++++++++++++--- > 4 files changed, 130 insertions(+), 6 deletions(-) > create mode 100644 Koha/TrackedLink.pm > create mode 100644 Koha/TrackedLinks.pm > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index c8b0d1cc91..3419305019 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -44,6 +44,7 @@ use Koha::Plugins; > use Koha::Libraries; > use Koha::StockRotationItem; > use Koha::StockRotationRotas; >+use Koha::TrackedLinks; > > use base qw(Koha::Object); > >@@ -1188,6 +1189,21 @@ sub orders { > return Koha::Acquisition::Orders->_new_from_dbic($orders); > } > >+=head3 tracked_links >+ >+ my $tracked_links = $item->tracked_links(); >+ >+Returns a Koha::TrackedLinks object >+ >+=cut >+ >+sub tracked_links { >+ my ( $self ) = @_; >+ >+ my $tracked_links = $self->_result->linktrackers; >+ return Koha::TrackedLinks->_new_from_dbic($tracked_links); >+} >+ > =head3 move_to_biblio > > $item->move_to_biblio($to_biblio[, $params]); >@@ -1254,9 +1270,9 @@ sub move_to_biblio { > } > ); > >- # linktrackers (there's no Koha object set available yet) >- my $linktrackers = $self->_result->linktrackers; >- $linktrackers->update_all({ biblionumber => $to_biblionumber }); >+ # tracked_links >+ my $tracked_links = $self->tracked_links; >+ $tracked_links->update({ biblionumber => $to_biblionumber }); > > return $to_biblionumber; > } >diff --git a/Koha/TrackedLink.pm b/Koha/TrackedLink.pm >new file mode 100644 >index 0000000000..7c7eeb871e >--- /dev/null >+++ b/Koha/TrackedLink.pm >@@ -0,0 +1,43 @@ >+package Koha::TrackedLink; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::TrackedLink - Koha TrackedLink Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Linktracker'; >+} >+ >+1; >diff --git a/Koha/TrackedLinks.pm b/Koha/TrackedLinks.pm >new file mode 100644 >index 0000000000..20ea4a90b2 >--- /dev/null >+++ b/Koha/TrackedLinks.pm >@@ -0,0 +1,49 @@ >+package Koha::TrackedLinks; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+ >+use Koha::Database; >+ >+use Koha::TrackedLink; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::TrackedLinks - Koha TrackedLink Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Linktracker'; >+} >+ >+sub object_class { >+ return 'Koha::TrackedLink'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index d03a60a30a..9260ca5282 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 12; > use Test::Exception; > > use C4::Biblio qw( GetMarcSubfieldStructure ); >@@ -38,6 +38,22 @@ use t::lib::Mocks; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >+subtest 'tracked_links relationship' => sub { >+ plan tests => 3; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ }); >+ my $tracked_links = $item->tracked_links; >+ is( ref($tracked_links), 'Koha::TrackedLinks', 'tracked_links returns a Koha::TrackedLinks object set' ); >+ is($item->tracked_links->count, 0, "Empty Koha::TrackedLinks set returned if no tracked_links"); >+ my $link1 = $builder->build({ source => 'Linktracker', value => { itemnumber => $item->itemnumber }}); >+ my $link2 = $builder->build({ source => 'Linktracker', value => { itemnumber => $item->itemnumber }}); >+ >+ is($item->tracked_links()->count,2,"Two tracked links found"); >+}; >+ > subtest 'hidden_in_opac() tests' => sub { > > plan tests => 4; >@@ -1034,8 +1050,8 @@ subtest 'move_to_biblio() tests' => sub { > > my $get_linktracker1 = $schema->resultset('Linktracker')->search({ itemnumber => $linktracker1->{itemnumber} })->single; > my $get_linktracker2 = $schema->resultset('Linktracker')->search({ itemnumber => $linktracker2->{itemnumber} })->single; >- is($get_linktracker1->biblionumber, $target_biblionumber, 'move_to_biblio moves linktracker for item 1'); >- is($get_linktracker2->biblionumber, $source_biblionumber, 'move_to_biblio does not move linktracker for item 2'); >+ is($get_linktracker1->biblionumber->biblionumber, $target_biblionumber, 'move_to_biblio moves linktracker for item 1'); >+ is($get_linktracker2->biblionumber->biblionumber, $source_biblionumber, 'move_to_biblio does not move linktracker for item 2'); > > $schema->storage->txn_rollback; > }; >-- >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