From 5e469596da1876a80dac272c73b5ba3d84240790 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Sat, 24 Nov 2007 15:10:18 -0600 Subject: [PATCH] fixing limit by availability, using nifty _ALLRECORDS in Zebra to handle NULL values Signed-off-by: Joshua Ferraro --- C4/Search.pm | 9 +++- etc/zebradb/biblios/etc/bib1.att | 62 ++++++++++++------------ etc/zebradb/biblios/etc/record.abs | 36 +++++++------- etc/zebradb/ccl.properties | 24 ++++----- misc/{ => cronjobs}/overduenotices-30.pl | 0 misc/{ => cronjobs}/overduenotices.pl | 0 6 files changed, 65 insertions(+), 66 deletions(-) rename misc/{ => cronjobs}/overduenotices-30.pl (100%) rename misc/{ => cronjobs}/overduenotices.pl (100%) diff --git a/C4/Search.pm b/C4/Search.pm index c277ff3e4f..340378ef3c 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -838,10 +838,11 @@ sub buildQuery { # add limits my $group_OR_limits; + my $availability_limit; foreach my $this_limit (@limits) { if ( $this_limit =~ /available/ ) { - # FIXME: switch to zebra search for null values - $limit .= " (($query and datedue=0000-00-00) or ($query and datedue=0000-00-00 not lost=1) or ($query and datedue=0000-00-00 not lost=2))"; + # available is defined as (items.notloan is NULL) and (items.itemlost > 0 or NULL) (last clause handles NULL values for lost in zebra) + $availability_limit .="( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and ((lost,st-numeric gt 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; $limit_cgi .= "&limit=available"; $limit_desc .=""; } @@ -867,6 +868,10 @@ sub buildQuery { $limit.=" and " if ($query || $limit ); $limit.="($group_OR_limits)"; } + if ($availability_limit) { + $limit.=" not " if ($query || $limit ); + $limit.="$availability_limit"; + } # normalize the strings for ($query, $query_desc, $limit, $limit_desc) { $_ =~ s/ / /g; # remove extra spaces diff --git a/etc/zebradb/biblios/etc/bib1.att b/etc/zebradb/biblios/etc/bib1.att index f5c8a8c53f..e4ed301fd2 100644 --- a/etc/zebradb/biblios/etc/bib1.att +++ b/etc/zebradb/biblios/etc/bib1.att @@ -117,37 +117,37 @@ att 9009 cn-prefix att 9010 cn-suffix # Items Index -att 8001 withdrawn -att 8002 lost -att 8003 classification-source -att 8004 materials-specified -att 8005 damaged -att 8006 restricted -att 8007 cn-sort -att 8008 notforloan -att 8009 ccode -att 8010 itemnumber -att 8011 homebranch -att 8012 holdingbranch -att 8013 location -att 8014 Date-of-acquisition -att 8015 acqsource -att 8016 coded-location-qualifier -att 8017 price -att 8018 stack -att 8019 issues -att 8020 renewals -att 8021 reserves -att 8022 Local-classification -att 8023 barcode -att 8024 onloan -att 8025 datelastseen -att 8026 datelastborrowed -att 8027 copynumber -att 8028 uri -att 8029 replacementprice -att 8030 replacementpricedate -att 8031 itype +att 8001 withdrawn +att 8002 lost +att 8003 classification-source +att 8004 materials-specified +att 8005 damaged +att 8006 restricted +att 8007 cn-sort +att 8008 notforloan +att 8009 ccode +att 8010 itemnumber +att 8011 homebranch +att 8012 holdingbranch +att 8013 location +att 8014 Date-of-acquisition +att 8015 acqsource +att 8016 coded-location-qualifier +att 8017 price +att 8018 stack +att 8019 issues +att 8020 renewals +att 8021 reserves +att 8022 Local-classification +att 8023 barcode +att 8024 onloan +att 8025 datelastseen +att 8026 datelastborrowed +att 8027 copynumber +att 8028 uri +att 8029 replacementprice +att 8030 replacementpricedate +att 8031 itype ## Fixed Fields and other special indexes att 9901 Extent diff --git a/etc/zebradb/biblios/etc/record.abs b/etc/zebradb/biblios/etc/record.abs index f7f0d85bdf..f356fe68be 100644 --- a/etc/zebradb/biblios/etc/record.abs +++ b/etc/zebradb/biblios/etc/record.abs @@ -227,11 +227,11 @@ melm 840 Title,Title-series ############################### # Koha Local-Use Biblio Indexes -melm 999$c Local-Number !:w,!:p,!:s -melm 999$d biblioitemnumber:n,!:s -melm 942$0 totalissues:n,!:s +melm 999$c Local-Number:n,Local-Number:w,Local-Number:s +melm 999$d biblioitemnumber:n,biblioitemnumber:w,biblioitemnumber:s +melm 942$0 totalissues:n,totalissues:s melm 942$2 cn-bib-source -melm 942$6 cn-bib-sort:n,!:s +melm 942$6 cn-bib-sort:n,cn-bib-sort:s melm 942$c itemtype:w # need to check bib1 @@ -241,16 +241,16 @@ melm 942$k cn-prefix melm 942$m cn-suffix # Items Indexes -melm 952$0 withdrawn:n,!:w -melm 952$1 lost:n,!:w +melm 952$0 withdrawn:n,withdrawn:w +melm 952$1 lost,lost:n melm 952$2 classification-source melm 952$3 materials-specified -melm 952$4 damaged:n,!:w -melm 952$5 restricted:n,!:w -melm 952$6 cn-sort:n,!:s -melm 952$7 notforloan:n,!:w +melm 952$4 damaged:n,damaged:w +melm 952$5 restricted:n,restricted:w +melm 952$6 cn-sort:n,cn-sort:s +melm 952$7 notforloan:n,notforloan:w melm 952$8 ccode -melm 952$9 itemnumber:n,!:s +melm 952$9 itemnumber:n,itemnumber:s melm 952$a homebranch melm 952$b holdingbranch melm 952$c location @@ -262,18 +262,18 @@ melm 952$f coded-location-qualifier melm 952$g price #melm 952$h #melm 952$i -melm 952$j stack:n,!:w +melm 952$j stack:n,stack:w #melm 952$k -melm 952$l issues:n,!:w,!:s -melm 952$m renewals:n,!:w -melm 952$n reserves:n,!:w +melm 952$l issues:n,issues:w,issues:s +melm 952$m renewals:n,renewals:w +melm 952$n reserves:n,reserves:w melm 952$o Local-classification:w,Local-classification:p,Local-classification:s -melm 952$p barcode,!:n -melm 952$q onloan:n,!:w +melm 952$p barcode,barcode:n +melm 952$q onloan:n,onloan:w melm 952$r datelastseen melm 952$s datelastborrowed melm 952$t copynumber -melm 952$u uri:u,!:w +melm 952$u uri:u,url:w melm 952$v replacementprice melm 952$w replacementpricedate #melm 952$x diff --git a/etc/zebradb/ccl.properties b/etc/zebradb/ccl.properties index c9a306cefd..1897565d82 100644 --- a/etc/zebradb/ccl.properties +++ b/etc/zebradb/ccl.properties @@ -822,7 +822,9 @@ relevance 2=102 rk 2=102 rank relevance +allrecords 1=_ALLRECORDS AlwaysMatches 2=103 + Within 2=104 ### 3. BIB1 POSITION ATTRIBUTES @@ -908,16 +910,16 @@ cn-prefix 1=9009 cn-suffix 1=9010 # Items Index -withdrawn 1=8001 4=109 -lost 1=8002 4=109 +withdrawn 1=8001 +lost 1=8002 classification-source 1=8003 materials-specified 1=8004 -damaged 1=8005 4=109 -restricted 1=8006 4=109 +damaged 1=8005 +restricted 1=8006 cn-sort 1=8007 -notforloan 1=8008 4=109 +notforloan 1=8008 ccode 1=8009 -itemnumber 1=8010 4=109 +itemnumber 1=8010 Code-institution 1=8011 holdingbranch 1=8012 location 1=8013 @@ -931,7 +933,7 @@ renewals 1=8020 4=109 reserves 1=8021 4=109 Local-classification 1=8022 barcode 1=8023 -onloan 1=8024 4=109 +onloan 1=8024 datelastseen 1=8025 datelastborrowed 1=8026 copynumber 1=8027 @@ -949,7 +951,6 @@ pl Place-publication # Extent #Extent 1=8001 -#Summary 1=8002 #att 8900 #Call-Number 1=8900 #date-entered-on-file 1=8800 @@ -963,10 +964,6 @@ ff8-34 1=8834 #att 8700 ff7-00 #att 8701 ff7-01 #att 8702 ff7-02 -#att 9520 withdrawn -#att 9521 lost -#lost 1=9521 4=109 -#att 9522 onloan ############## SUBJECT-RELATED # Topical Term @@ -1017,9 +1014,6 @@ Illustration-code 1=Illustration-code #yr 1=8801 4=109 r=r ## STATUSES -onloan 1=9522 -datedue 1=9522 - popularity 1=issues # Material Category diff --git a/misc/overduenotices-30.pl b/misc/cronjobs/overduenotices-30.pl similarity index 100% rename from misc/overduenotices-30.pl rename to misc/cronjobs/overduenotices-30.pl diff --git a/misc/overduenotices.pl b/misc/cronjobs/overduenotices.pl similarity index 100% rename from misc/overduenotices.pl rename to misc/cronjobs/overduenotices.pl -- 2.39.5