Bugzilla – Attachment 161546 Details for
Bug 35921
Improve performance of acquisitions start page when there are many budgets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35921: Improve perfs of acqui-home.pl when there are many budgets
Bug-35921-Improve-perfs-of-acqui-homepl-when-there.patch (text/plain), 2.27 KB, created by
Julian Maurice
on 2024-01-26 15:19:43 UTC
(
hide
)
Description:
Bug 35921: Improve perfs of acqui-home.pl when there are many budgets
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2024-01-26 15:19:43 UTC
Size:
2.27 KB
patch
obsolete
>From b332942be867155669e7660e5bcfd4fa339a172a Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 25 Jan 2024 16:49:32 +0100 >Subject: [PATCH] Bug 35921: Improve perfs of acqui-home.pl when there are many > budgets > >When there are a lot of budgets with the same owner, most of the time of >acqui-home.pl is spent loading the same patron over and over. > >This patch makes sure each borrower is loaded only once. > >Test plan: >0. Do not apply the patch yet >1. Create a thousand budgets with the following command (make sure the > budget_owner_id is an existing borrowernumber): > perl -MKoha::Database -e ' > my $schema = Koha::Database->schema; > my $period = $schema->resultset("Aqbudgetperiod")->create({ > budget_period_startdate => "2000-01-01", > budget_period_enddate => "2999-12-31" > }); > $schema->resultset("Aqbudget")->create({ > budget_owner_id => 1, > budget_period_id => $period->id > }) for (1..1000) > ' >2. Measure the time it takes to load acqui/acqui-home.pl (do it several > times and keep the average time) >3. Apply the patch >4. Repeat step 2 >--- > acqui/acqui-home.pl | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > >diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl >index 05eb16bf06d..87a460b9d5e 100755 >--- a/acqui/acqui-home.pl >+++ b/acqui/acqui-home.pl >@@ -76,12 +76,16 @@ my $totordered_active = 0; > my $totavail_active = 0; > > my @budget_loop; >+my %patrons = ($loggedinuser => Koha::Patrons->find($loggedinuser)); >+my $loggedinpatron = $patrons{$loggedinuser}->unblessed; > foreach my $budget ( @{$budget_arr} ) { >- next unless (CanUserUseBudget($loggedinuser, $budget, $userflags)); >+ next unless (CanUserUseBudget($loggedinpatron, $budget, $userflags)); > >- my $patron = Koha::Patrons->find( $budget->{budget_owner_id} ); >- if ( $patron ) { >- $budget->{budget_owner} = $patron; >+ if ( my $borrowernumber = $budget->{budget_owner_id} ) { >+ unless (exists $patrons{$borrowernumber}) { >+ $patrons{$borrowernumber} = Koha::Patrons->find($borrowernumber); >+ } >+ $budget->{budget_owner} = $patrons{$borrowernumber}; > } > > if ( !defined $budget->{budget_amount} ) { >-- >2.30.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 35921
:
161546
|
162372
|
162373
|
163288
|
163336
|
163337