Bugzilla – Attachment 167393 Details for
Bug 36672
Circulation rules are performing too many lookups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36672: Circulation rules are performing too many lookups
Bug-36672-Circulation-rules-are-performing-too-man.patch (text/plain), 6.50 KB, created by
Martin Renvoize
on 2024-06-04 12:18:08 UTC
(
hide
)
Description:
Bug 36672: Circulation rules are performing too many lookups
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-06-04 12:18:08 UTC
Size:
6.50 KB
patch
obsolete
>From 79d93f001dc877545b6e3c858632ab1091476e56 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 26 Apr 2024 17:41:06 +0000 >Subject: [PATCH] Bug 36672: Circulation rules are performing too many lookups > >Looking at the template, for every section after the main rules block we loop over categories or itemtypes, and lookup the value for each rule name. > >In systems with large numbers of categories and item types this becomes very slow. > >In the rules section, we have already built a hash of rules by category and itemtype - we should continue to use this throughout the page. > >Test Plan: >1) Apply this patch >2) For each rule section, create and delete a rule >3) No change in behavior should be noted! > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/admin/smart-rules.tt | 30 +++++++++---------- > 1 file changed, 15 insertions(+), 15 deletions(-) > >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 8d0562edab8..26d44e54c61 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 >@@ -824,9 +824,10 @@ > </tr> > [% FOREACH c IN categorycodes %] > [% NEXT UNLESS c %] >- [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %] >- [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %] >- [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %] >+ [% SET i = undef %] >+ [% SET patron_maxissueqty = all_rules.$c.$i.patron_maxissueqty %] >+ [% SET patron_maxonsiteissueqty = all_rules.$c.$i.patron_maxonsiteissueqty %] >+ [% SET max_holds = all_rules.$c.$i.max_holds %] > > [% IF ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %] > <tr> >@@ -902,11 +903,8 @@ > <th> </th> > </tr> > [% FOREACH c IN categorycodes %] >- [% SET c = '*' UNLESS c.defined AND c != '' %] > [% FOREACH i IN itemtypes %] >- [% SET i = '*' UNLESS i.defined AND i != '' %] >- >- [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %] >+ [% SET waiting_hold_cancellation = all_rules.$c.$i.waiting_hold_cancellation %] > > [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %] > <tr> >@@ -932,7 +930,7 @@ > [% END %] > </td> > <td class="actions"> >- <a href="#" class="del-waiting-hold-cancellation btn btn-default btn-xs" data-categorycode="[% c | html %]" data-itemtype="[% i | html %]" data-branch"[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a> >+ <a href="#" class="del-waiting-hold-cancellation btn btn-default btn-xs" data-categorycode="[% c || '*' | html %]" data-itemtype="[% i|| '*' | html %]" data-branch"[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a> > </td> > </tr> > [% END %] >@@ -987,7 +985,8 @@ > </tr> > [% FOREACH c IN categorycodes %] > [% NEXT UNLESS c %] >- [% SET open_article_requests_limit = CirculationRules.Search( branchcode, c, undef, 'open_article_requests_limit' ) %] >+ [% SET i = undef %] >+ [% SET open_article_requests_limit = all_rules.$c.$i.open_article_requests_limit %] > > [% IF ( open_article_requests_limit.defined && open_article_requests_limit != '' ) %] > <tr> >@@ -1041,9 +1040,8 @@ > <th> </th> > </tr> > [% FOREACH c IN categorycodes %] >- [% SET c = '*' UNLESS c.defined AND c != '' %] >- >- [% SET article_request_fee = CirculationRules.Search( current_branch, c, undef, 'article_request_fee' ) %] >+ [% SET i = undef %] >+ [% SET article_request_fee = all_rules.$c.$i.article_request_fee %] > > [% IF ( article_request_fee.defined && article_request_fee != '' ) %] > <tr> >@@ -1307,9 +1305,11 @@ > <th> </th> > </tr> > [% FOREACH i IN itemtypeloop %] >- [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %] >- [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %] >- [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %] >+ [% SET it = i.itemtype %] >+ [% SET c = undef %] >+ [% SET holdallowed = all_rules.$c.$it.holdallowed %] >+ [% SET hold_fulfillment_policy = all_rules.$c.$it.hold_fulfillment_policy %] >+ [% SET returnbranch = all_rules.$c.$it.returnbranch %] > > [% IF holdallowed || hold_fulfillment_policy || returnbranch %] > <tr> >-- >2.45.1
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 36672
:
165685
|
165687
|
166151
| 167393