Bug 36155 - Improve perfs of suggestion.pl when there are many budgets
Summary: Improve perfs of suggestion.pl when there are many budgets
Status: Patch doesn't apply
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 7923
  Show dependency treegraph
 
Reported: 2024-02-23 07:53 UTC by Fridolin Somers
Modified: 2024-02-29 10:02 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 36155: Improve perfs of suggestion.pl when there are many budgets (4.57 KB, patch)
2024-02-23 08:49 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 36155: Improve perfs of suggestion.pl when there are many budgets (4.63 KB, patch)
2024-02-23 10:22 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2024-02-23 07:53:34 UTC
Page suggestion/suggestion.pl always calls GetBudgets() and GetBudgetHierarchy().
But the result are not always used in template.
When there are many budgets and funds this takes some time.
Also CanUserUseBudget() in a loop should use a unique Koha::Patron object of the logged in user.
Comment 1 Fridolin Somers 2024-02-23 08:38:54 UTC
(In reply to Fridolin Somers from comment #0)
> Also CanUserUseBudget() in a loop should use a unique Koha::Patron object of
> the logged in user.
Ah I mean a unblessed Koha::Patron object of logged in user
Comment 2 Fridolin Somers 2024-02-23 08:49:07 UTC
Created attachment 162364 [details] [review]
Bug 36155: Improve perfs of suggestion.pl when there are many budgets

Page suggestion/suggestion.pl always calls GetBudgets() and GetBudgetHierarchy().
But the result are not always used in template.
When there are many budgets and funds this takes some time.
Also CanUserUseBudget() in a loop should use a unique Koha::Patron unblessed object of the logged in user.

Test plan :
1) Create a user 'P1' with permissions 'catalogue', 'suggestions_manage'
   and all permissions on acquisition except 'budget_manage_all'
2) Create some funds and subfunds without restricted access
3) Create a fund 'F1' with owner other than 'P1' and restricted access on owner
4) Go to staff interface with patron 'P1'
5) Go to Acquisitions > Suggestions
6) Check you see all founds except F1 in Filter by > Acquisition information
7) Create a new suggestion
8) Check you see all founds except F1 in Fund
9) Select a fund and save
10) Edit this suggestion
11) Check you see all founds except F1 in Fund
12) Compare performance with and without patch with many budgets and funds
    (see test plan of Bug 35921)
Comment 3 Fridolin Somers 2024-02-23 09:18:15 UTC
Applyed on a Koha with :
67 aqbudgetperiods
1605 aqbudgets

Timings :
suggestion.pl?op=add : 14s > 2s
suggestion.pl?op=edit : 14s > 2s
suggestion.pl?op=show : 20s > 8s

Whaouuu :D
Comment 4 Pedro Amorim 2024-02-23 10:22:02 UTC
Created attachment 162371 [details] [review]
Bug 36155: Improve perfs of suggestion.pl when there are many budgets

Page suggestion/suggestion.pl always calls GetBudgets() and GetBudgetHierarchy().
But the result are not always used in template.
When there are many budgets and funds this takes some time.
Also CanUserUseBudget() in a loop should use a unique Koha::Patron unblessed object of the logged in user.

Test plan :
1) Create a user 'P1' with permissions 'catalogue', 'suggestions_manage'
   and all permissions on acquisition except 'budget_manage_all'
2) Create some funds and subfunds without restricted access
3) Create a fund 'F1' with owner other than 'P1' and restricted access on owner
4) Go to staff interface with patron 'P1'
5) Go to Acquisitions > Suggestions
6) Check you see all founds except F1 in Filter by > Acquisition information
7) Create a new suggestion
8) Check you see all founds except F1 in Fund
9) Select a fund and save
10) Edit this suggestion
11) Check you see all founds except F1 in Fund
12) Compare performance with and without patch with many budgets and funds
    (see test plan of Bug 35921)

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 5 Jonathan Druart 2024-02-29 10:02:08 UTC
Will need to be rebased on top of 34478 when pushed.