Bugzilla – Attachment 169159 Details for
Bug 37389
REST API queries joining on extended_attributes may cause severe performance issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37389: Working accessors
Bug-37389-Working-accessors.patch (text/plain), 2.91 KB, created by
Martin Renvoize
on 2024-07-18 17:21:36 UTC
(
hide
)
Description:
Bug 37389: Working accessors
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-07-18 17:21:36 UTC
Size:
2.91 KB
patch
obsolete
>From 88d1257a6935a30ee54775baa1044f6d787fec64 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 18 Jul 2024 17:33:37 +0100 >Subject: [PATCH] Bug 37389: Working accessors > >--- > Koha/ILL/Requests.pm | 25 +++++-------------------- > Koha/REST/Plugin/Query.pm | 5 +++-- > 2 files changed, 8 insertions(+), 22 deletions(-) > >diff --git a/Koha/ILL/Requests.pm b/Koha/ILL/Requests.pm >index 289ce73d97b..a8435d1b6a1 100644 >--- a/Koha/ILL/Requests.pm >+++ b/Koha/ILL/Requests.pm >@@ -120,18 +120,11 @@ Returns a list of relation accessor names. > =cut > > sub _build_extended_attributes_relations { >- my ($self) = @_; >- >- my @distinct_types = Koha::ILL::Request::Attributes->_resultset->search( >- {}, # No specific conditions >- { >- select => ['type'], >- group_by => ['type'] >- } >- )->get_column('type')->all; >+ my ( $self, $types ) = @_; > >- for my $type (@distinct_types) { >- my $test = $self->_resultset->_result_class->has_many( >+ my $result_source = $self->_resultset->result_source; >+ for my $type ( @{$types} ) { >+ $result_source->add_relationship( > "extended_attributes_$type", > "Koha::Schema::Result::Illrequestattribute", > sub { >@@ -145,16 +138,8 @@ sub _build_extended_attributes_relations { > { cascade_copy => 0, cascade_delete => 0 }, > ); > >- my $schema = $self->_resultset->result_source->schema; >- >- $schema->unregister_source('Koha::Schema::Result::Illrequest'); >- $schema->register_class( 'Koha::Schema::Result::Illrequest', $test ); >- >- # Testing to check if the dynamically added method has been aded. It's not been!! >- $self->find(1)->extended_attributes_article_title; > } >- >- return map { 'extended_attributes_'.$_ } @distinct_types; >+ return map { 'extended_attributes_' . $_ } @{$types}; > } > > =head3 _type >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index 1c80323d4a7..2c4364cc91f 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -181,11 +181,12 @@ Generates the DBIC join attribute based on extended_attributes query entries, an > { > # my $ea_entries = $self->_get_extended_attributes_entries( $filtered_params, 0 ); > >+ my @types = qw( article_title issue volume ); >+ > # Calling our private method to build the extended attributes relations >- $result_set->_build_extended_attributes_relations(); >+ my @test = $result_set->_build_extended_attributes_relations(\@types); > > # Testing out the extended attributes join (hardcoded for now) >- my @test = qw( extended_attributes_article_title extended_attributes_issue extended_attributes_volume ); > foreach my $test (@test) { > push( @{ $attributes->{join} }, $test ); > } >-- >2.45.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 37389
:
169130
|
169133
|
169140
|
169149
|
169159
|
169178
|
169185
|
169189
|
169191
|
169192
|
169234
|
169243
|
169244
|
169245
|
169246
|
169317
|
169318
|
169569
|
169570
|
169583
|
169584
|
169585
|
169586
|
169850
|
169851
|
169944
|
169945
|
169946
|
169954
|
169955
|
169956