Bugzilla – Attachment 151077 Details for
Bug 31856
Improve performance of serials subscriptions search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31856: Prefetch additional fields for increased performance
Bug-31856-Prefetch-additional-fields-for-increased.patch (text/plain), 2.62 KB, created by
David Gustafsson
on 2023-05-11 13:19:40 UTC
(
hide
)
Description:
Bug 31856: Prefetch additional fields for increased performance
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2023-05-11 13:19:40 UTC
Size:
2.62 KB
patch
obsolete
>From 4d76cd552f24b3806b1546ece42259ac6723868c Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Wed, 10 May 2023 16:02:51 +0200 >Subject: [PATCH] Bug 31856: Prefetch additional fields for increased > performance > >--- > C4/Serials.pm | 40 +++++++++++++++++++++------------------- > 1 file changed, 21 insertions(+), 19 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 0ac8802d3ac..7cf89014715 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -616,32 +616,34 @@ sub SearchSubscriptions { > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute(@where_args); >- my $results = $sth->fetchall_arrayref( {} ); >+ my $results = $sth->fetchall_arrayref( {} ); > > my %additional_fields_by_id = map { $_->id => $_->name } Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; >- >- for my $subscription ( @$results ) { >- $subscription->{cannotedit} = not can_edit_subscription( $subscription ); >- $subscription->{cannotdisplay} = not can_show_subscription( $subscription ); >- >- if (%additional_fields_by_id) { >- my @additional_field_values = Koha::AdditionalFieldValues->search( >- { >- field_id => { -in => [ keys %additional_fields_by_id ] }, >- record_id => $subscription->{subscriptionid} >- } >- )->as_list; >- >- $subscription->{additional_fields} = { >- map { $additional_fields_by_id{$_->field_id} => $_->value } @additional_field_values >- }; >+ if (%additional_fields_by_id) { >+ my %subscriptions_by_id = map { $_->{subscriptionid } => $_ } @{$results}; >+ my $field_values_rs = Koha::AdditionalFieldValues->search( >+ { >+ field_id => { -in => [ keys %additional_fields_by_id ] }, >+ record_id => { -in => [ keys %subscriptions_by_id ] } >+ } >+ ); >+ while (my $field_value = $field_values_rs->next) { >+ my $field_name = $additional_fields_by_id{$field_value->field_id}; >+ $subscriptions_by_id{$field_value->record_id}->{additional_fields}->{$field_name} = $field_value->value; > } >- else { >+ } >+ else { >+ for my $subscription ( @{$results} ) { > $subscription->{additional_fields} = {}; > } > } > >- return @$results; >+ for my $subscription ( @{$results} ) { >+ $subscription->{cannotedit} = not can_edit_subscription( $subscription ); >+ $subscription->{cannotdisplay} = not can_show_subscription( $subscription ); >+ } >+ >+ return @{$results}; > } > > >-- >2.40.0
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 31856
:
142058
|
142156
|
142157
|
150651
|
150652
|
150653
| 151077 |
151078