Bug 29685: Reduce item processing by calculating 'items any available' outside of...
authorNick Clemens <nick@bywatersolutions.com>
Mon, 13 Dec 2021 12:01:24 +0000 (12:01 +0000)
committerAndrew Fuerste-Henry <andrew@bywatersolutions.com>
Tue, 25 Jan 2022 17:11:32 +0000 (17:11 +0000)
commit27cd3738fdfa9f0b403fa1a4d2bcb0a2c9716807
tree28c0a9b76eb37b1591d66ded92cdafc20854f3b0
parent62b64180dd4caf8b052ceb2a74e6c014a5f7d17d
Bug 29685: Reduce item processing by calculating 'items any available' outside of loop

See bug 24185, this avoids looping every each item of the record for every item of the record

How to reproduce:

1) on freshly installed kohadevbox create/import one book,
remember that biblionumber for later use it in down below,

2) add 100 items for that book for some library,

3) find some patron, that patron's card number we will
use as a borrower down below to open holds page,

4) check for the rule or set up a single circulation rule
in admin "/cgi-bin/koha/admin/smart-rules.pl",
that rule should match above book items/library/patron,
check that rule to have a non-zero number of holds (total, daily, count) allowed,
and, IMPORTANT: set up "On shelf holds allowed" to "If all unavailable",
("item level holds" doesn't matter).

5) open "Home > Catalog > THAT_BOOK > Place a hold on THAT_BOOK" page
("holds" tab), and enter patron code in the search field,
or you can create a direct link by yourself, for example, in my case it was:
/cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=23529000686353

6) it should be pretty long page generation time on old code, densely increasing for every hundred items added. In the case of this solution, it's fast, and time increases a little only, linear.

In testing with 100 books I went from ~6.5 seconds to ~3.2 seconds

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 2213cb9152d17595ef102d0de5516c4eee023ae9)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
opac/opac-reserve.pl