From 90b33cea9a005db1f54cb161c49297f1f6513cca Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sun, 11 Aug 2019 16:11:30 +0000 Subject: [PATCH] Bug 11677: Use zebra not-onloan-count index for availability limit This uses the work from bug 18098 to use the count of not-onloan items to determine availability. Note that availability in this sense means not check out and not lost. Transfers, holds, and not for loan statuses should probably have indexes built in the same way as bug 18098 (there are related fixmes in the code) To test: 1 - make sure SearchEngine pref is set to 'Zebra' 2 - Do a search on the OPAC that returns some records 3 - Find a record in those results with more than one 1 item, and checkout 1 leaving 1 (or more) available 4 - Find another record with only 1 item, check that item out 5 - Limit opac search to available items - both records disappear 6 - Apply patch 7 - Restart all the things 8 - Repeat search 9 - First record should show, but no second 10 - Mark other items of first record as lost, return items on second record 11 - Repeat search, first record should not be in results, second should --- C4/Search.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 4c4a3d0e10..f8c52651e5 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1689,9 +1689,8 @@ sub buildQuery { # ## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) ## In English: -## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 - $availability_limit .= -"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; +## all records with a not-onloan-count > 0 and all records with a value of lost equal to 0 + $availability_limit .= "( (not-onloan-count,st-numeric>0) and (lost,st-numeric=0) )"; $limit_cgi .= "&limit=available"; $limit_desc .= ""; } -- 2.11.0