Bugzilla – Attachment 169178 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), 3.51 KB, created by
Martin Renvoize
on 2024-07-19 07:21:51 UTC
(
hide
)
Description:
Bug 37389: Working accessors
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-07-19 07:21:51 UTC
Size:
3.51 KB
patch
obsolete
>From 031d6e37f908efe8d7bcf7928f8a2578ba80be1f 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 | 59 +++++++++++++++------------------------ > Koha/REST/Plugin/Query.pm | 7 +++-- > 2 files changed, 26 insertions(+), 40 deletions(-) > >diff --git a/Koha/ILL/Requests.pm b/Koha/ILL/Requests.pm >index cdf2a9de4a3..a8435d1b6a1 100644 >--- a/Koha/ILL/Requests.pm >+++ b/Koha/ILL/Requests.pm >@@ -119,43 +119,28 @@ 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; >- >-# for my $type (@distinct_types) { >-# my $test = $self->_resultset->_result_class->has_many( >-# "extended_attributes_$type", >-# "Koha::Schema::Result::Illrequestattribute", >-# sub { >-# my $args = shift; >- >-# return { >-# "$args->{foreign_alias}.illrequest_id" => { -ident => "$args->{self_alias}.illrequest_id" }, >-# "$args->{foreign_alias}.type" => { '=', $type }, >-# }; >-# }, >-# { 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; >-# } >+sub _build_extended_attributes_relations { >+ my ( $self, $types ) = @_; >+ >+ my $result_source = $self->_resultset->result_source; >+ for my $type ( @{$types} ) { >+ $result_source->add_relationship( >+ "extended_attributes_$type", >+ "Koha::Schema::Result::Illrequestattribute", >+ sub { >+ my $args = shift; >+ >+ return { >+ "$args->{foreign_alias}.illrequest_id" => { -ident => "$args->{self_alias}.illrequest_id" }, >+ "$args->{foreign_alias}.type" => { '=', $type }, >+ }; >+ }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+ ); >+ >+ } >+ return map { 'extended_attributes_' . $_ } @{$types}; >+} > > =head3 _type > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index 7927bde4232..d159fef0f67 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -181,9 +181,10 @@ Generates the DBIC join attribute based on extended_attributes query entries, an > { > my @array = $self->_get_extended_attributes_entries( $filtered_params, 0 ); > >- foreach my $test (@array) { >- push( @{ $attributes->{join} }, 'extended_attributes_'.$test ); >- } >+ # Calling our private method to build the extended attributes relations >+ my @joins = $result_set->_build_extended_attributes_relations(\@array); >+ push @{$ attributes->{join} }, @joins; >+ > } > } > ); >-- >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