This patch implements an algorithm for selecting the item that would leave the largest gap after the proposed booking to maximize the opportunity for future bookings. Key Changes: Koha::Booking: - Added set_itemtype_filter() method for transient itemtype parameter - Added _select_optimal_item() method using single aggregated query * Groups bookings by item_id with MIN(start_date) * Selects items with no future bookings (optimal) * Among items with bookings, selects one with latest next booking * O(1) complexity - single database query with GROUP BY - Updated _assign_item_for_booking() to use optimal selection * Filters by itemtype when itemtype_id is provided * Replaces previous random selection (RAND()) API Changes: - Added itemtype_id parameter support to add() endpoint - Added itemtype_id parameter support to update() endpoint - Validates exactly one of item_id or itemtype_id is provided - itemtype_id is transient - not persisted to database - Extracted and applied via set_itemtype_filter() before store() Architecture: - itemtype_id is NOT a database column (transient only) - Used as selection criterion, then discarded Test plan: 1. Apply patch and restart services 2. Create "any item" booking via staff interface 3. Verify item with longest future availability is selected 4. Test via API with itemtype_id parameter 5. Verify itemtype_id is not persisted to database 6. Run t/db_dependent/Koha/Booking.t 7. Run t/db_dependent/api/v1/bookings.t Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> |
||
|---|---|---|
| .. | ||
| swagger | ||
| app.pl | ||