Bug 36155: Improve perfs of suggestion.pl when there are many budgets

Page suggestion/suggestion.pl calls CanUserUseBudget() in a loop,
will must use a uniq Koha::Patron object of the logged in user.
When there are many budgets and funds this takes some time.

Test plan :
Compare performance with and without patch with many budgets and funds
(see test plan of Bug 35921)

Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 10c8a373fb)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Fridolin Somers 2024-02-23 08:59:30 +01:00 committed by Paul Derscheid
parent ad886b5869
commit b3704edcac
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 1 additions and 1 deletions

View File

@ -548,7 +548,7 @@ $template->param( patron_reason_loop => $patron_reason_loop );
my $sugg_budget_loop = [];
my $sugg_budgets = GetBudgetHierarchy();
foreach my $r ( @{$sugg_budgets} ) {
next unless ( CanUserUseBudget( $borrowernumber, $r, $userflags ) );
next unless ( CanUserUseBudget( $librarian->unblessed, $r, $userflags ) );
my $selected = ( $$suggestion_ref{budgetid} && $r->{budget_id} eq $$suggestion_ref{budgetid} ) ? 1 : 0;
push @{$sugg_budget_loop},
{