Bugzilla – Attachment 164121 Details for
Bug 36447
Circ rules slow to load when many itemtypes and categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36447: Circ rules slow to load when many itemtypes and categories
Bug-36447-Circ-rules-slow-to-load-when-many-itemty.patch (text/plain), 3.44 KB, created by
Marcel de Rooy
on 2024-03-29 09:46:00 UTC
(
hide
)
Description:
Bug 36447: Circ rules slow to load when many itemtypes and categories
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-03-29 09:46:00 UTC
Size:
3.44 KB
patch
obsolete
>From 666520df08d5986c446ad58e9baf325a859c1bec Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 28 Mar 2024 10:55:05 -0400 >Subject: [PATCH] Bug 36447: Circ rules slow to load when many itemtypes and > categories >Content-Type: text/plain; charset=utf-8 > >It seems that we loop all categories and item types to build the circ >matrix. We should only loop over values that have actually been used >in circulation rules. > >Test Plan: >1) Create 1000 itemtypes and category codes. You can use the following > script: > > use t::lib::TestBuilder; > my $builder = t::lib::TestBuilder->new(); > $builder->build( { source => 'Category' } ) for 0..1000; > $builder->build( { source => 'Itemtype' } ) for 0..1000; > >2) Note the lengthy load time for smart-rules.pl >3) Apply this patch >4) Restart all the things! >5) Reload the page >6) Note the much faster load time! > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > admin/smart-rules.pl | 19 +++++++++++++------ > .../prog/en/modules/admin/smart-rules.tt | 13 ++----------- > 2 files changed, 15 insertions(+), 17 deletions(-) > >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index f5f168f44f..16faa8b06c 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -739,6 +739,11 @@ my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['des > > my $itemtypes = Koha::ItemTypes->search_with_localization; > >+my @used_categorycodes = >+ Koha::CirculationRules->search( {}, { columns => ['categorycode'], distinct => 1, } )->get_column('categorycode'); >+my @used_itemtypes = >+ Koha::CirculationRules->search( {}, { columns => ['itemtype'], distinct => 1, } )->get_column('itemtype'); >+ > my $humanbranch = ( $branch ne '*' ? $branch : undef ); > > my $all_rules = Koha::CirculationRules->search({ branchcode => $humanbranch }); >@@ -753,12 +758,14 @@ while ( my $r = $all_rules->next ) { > $template->param(show_branch_cat_rule_form => 1); > > $template->param( >- patron_categories => $patron_categories, >- itemtypeloop => $itemtypes, >- humanbranch => $humanbranch, >- current_branch => $branch, >- definedbranch => $definedbranch, >- all_rules => $rules, >+ used_categorycodes => \@used_categorycodes, >+ used_itemtypes => \@used_itemtypes, >+ patron_categories => $patron_categories, >+ itemtypeloop => $itemtypes, >+ humanbranch => $humanbranch, >+ current_branch => $branch, >+ definedbranch => $definedbranch, >+ all_rules => $rules, > ); > output_html_with_http_headers $input, $cookie, $template->output; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index f536ef9760..1109b0e99c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -12,17 +12,8 @@ > > [% SET branchcode = humanbranch || undef %] > >-[% SET categorycodes = [] %] >-[% FOREACH pc IN patron_categories %] >- [% categorycodes.push( pc.id ) %] >-[% END %] >-[% categorycodes.push(undef) %] >- >-[% SET itemtypes = [] %] >-[% FOREACH i IN itemtypeloop %] >- [% itemtypes.push( i.itemtype ) %] >-[% END %] >-[% itemtypes.push(undef) %] >+[% SET categorycodes = used_categorycodes %] >+[% SET itemtypes = used_itemtypes %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>[% FILTER collapse %] >-- >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 36447
:
164065
|
164083
| 164121