Bug 29702: Fetch group libraries in a single call
authorNick Clemens <nick@bywatersolutions.com>
Wed, 15 Dec 2021 15:44:06 +0000 (15:44 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 14 Jan 2022 08:12:53 +0000 (22:12 -1000)
commit9d31f0d4ed98654477db9d17bfee2365169da8ee
treeaa40357f15da28a1e7d589105d54baaeda8f2397
parent2f554fd2882d60f352d146ae2b78cf4998eee85a
Bug 29702: Fetch group libraries in a single call

The current code gets all group members, then loops through and fetches the library if there is a
branchcode, or recursively calls itself if a group. This slows down performance.

We can utilize the 'libraries' method to get all child libraries at once, then make a check
for child groups separately

To recreate:
 1 - Add 100 items to a biblio
 2 - Define a library group as a hold group
 3 - Add all libraries to the group
 4 - Set 'Default checkout, hold and return policy'->'Hold pickup library match' = 'Any library'
 5 - place a hold on the record and note load time after patron is selected
 6 - Set 'Default checkout, hold and return policy'->'Hold pickup library match' = 'Patrons hold group'
 7 - place a hold, note longer load time after patron selection
 8 - Apply patch
 9 - note improvement
10 - prove -v t/db_dependent/Koha/Libraries.t

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/Library/Group.pm