Commit Graph

10 Commits

Author SHA1 Message Date
Martin Renvoize 4a658430a3
Bug 28530: (QA follow-up) Fix branch transfer limits not checking alternate libraries
Fixed a pre-existing bug where branch transfer limits would prevent ANY
transfer if the optimal library was blocked, instead of trying the next
best candidate.

Original behavior:
- Sort candidates by best ratio
- Check if transfer to best candidate is allowed
- If not allowed: exit loop immediately (bug!) and return undef
- Result: No transfer created even if other valid candidates exist

Fixed behavior:
- Sort candidates by best ratio
- Check if transfer to best candidate is allowed
- If allowed: use that library and exit loop
- If not allowed: continue to next candidate
- Result: Uses the best ALLOWED candidate

This fix ensures that when branch transfer limits block the optimal
destination, the system will try the next-best option instead of
giving up entirely.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:43 -07:00
Martin Renvoize 7076f57bd8
Bug 28530: (QA follow-up) Fix N+1 query performance issue
Refactored lowest_ratio_library() to eliminate the N+1 query problem
by using aggregated queries with GROUP BY instead of per-branch queries.

Performance improvement:
- Before: O(3n) queries where n = number of branches with float limits
  Example: 20 branches = 60 database queries
- After: O(3) queries regardless of number of branches
  Example: 20 branches = 3 database queries

The optimization uses three aggregated queries:
1. Single query with GROUP BY to get item counts at all branches
2. Single query with GROUP BY to get in-transit-to counts for all branches
3. Single query with GROUP BY to get in-transit-from counts for all branches

Results are combined in memory to calculate ratios, maintaining identical
logic and behavior while dramatically improving database efficiency.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:42 -07:00
Martin Renvoize 30fd316872
Bug 28530: (QA follow-up) Add POD documentation and database index
- Add comprehensive POD documentation for lowest_ratio_library() method
  including parameter descriptions, return values, and algorithm explanation
- Add database index on itemtype column in library_float_limits table
  to improve query performance when searching by itemtype

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:42 -07:00
Martin Renvoize 24afe8e36e
Bug 28530: (QA follow-up) Guard against divide by zero
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:41 -07:00
Lucas Gass 06b352a32a
Bug 28530: Fix spelling mistakes
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:39 -07:00
Lucas Gass 336d48eae2
Bug 28530: Fix forbidden http pattern
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:38 -07:00
Lucas Gass 026da298f4
Bug 28530: Increment and decrement item count before calculation
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:37 -07:00
Lucas Gass ef899660a0
Bug 28530: If return policy is set to float in library group, remove non group branches
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:36 -07:00
Lucas Gass 1f63d8c13f
Bug 28530: Implement float limits
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:35 -07:00
Kyle M Hall a6a446ad39
Bug 28530: Add Koha Object(s) for Float Limits
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-10 10:51:34 -07:00