LP#1698206: Make use of current search library in autosuggest
authorMike Rylander <mrylander@gmail.com>
Wed, 19 Jul 2017 18:07:39 +0000 (14:07 -0400)
committerKathy Lussier <klussier@masslnc.org>
Mon, 28 Aug 2017 15:14:53 +0000 (11:14 -0400)
Here we teach autosuggest how to check the opac search scope.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/sql/Pg/030.schema.metabib.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_vis_attr_cache.sql

index f79d09e..fb9a83f 100644 (file)
@@ -1826,11 +1826,22 @@ BEGIN
 
     visibility_org := NULLIF(visibility_org,-1);
     IF visibility_org IS NOT NULL THEN
-        opac_visibility_join := '
-    JOIN asset.opac_visible_copies aovc ON (
-        aovc.record = x.source AND
-        aovc.circ_lib IN (SELECT id FROM actor.org_unit_descendants($4))
-    )';
+        PERFORM FROM actor.org_unit WHERE id = visibility_org AND parent_ou IS NULL;
+        IF FOUND THEN
+            opac_visibility_join := '';
+        ELSE
+            opac_visibility_join := '
+    JOIN asset.copy_vis_attr_cache acvac ON (acvac.record = x.source)
+    JOIN vm ON (acvac.vis_attr_vector @@
+            (vm.c_attrs || $$&$$ ||
+                search.calculate_visibility_attribute_test(
+                    $$circ_lib$$,
+                    (SELECT ARRAY_AGG(id) FROM actor.org_unit_descendants($4))
+                )
+            )::query_int
+         )
+';
+        END IF;
     ELSE
         opac_visibility_join := '';
     END IF;
index 906c82a..c554f24 100644 (file)
@@ -437,10 +437,22 @@ BEGIN
 
     visibility_org := NULLIF(visibility_org,-1);
     IF visibility_org IS NOT NULL THEN
-        opac_visibility_join := '
+        PERFORM FROM actor.org_unit WHERE id = visibility_org AND parent_ou IS NULL;
+        IF FOUND THEN
+            opac_visibility_join := '';
+        ELSE
+            opac_visibility_join := '
     JOIN asset.copy_vis_attr_cache acvac ON (acvac.record = x.source)
-    JOIN vm ON (acvac.vis_attr_vector @@ vm.c_attrs::query_int)
+    JOIN vm ON (acvac.vis_attr_vector @@
+            (vm.c_attrs || $$&$$ ||
+                search.calculate_visibility_attribute_test(
+                    $$circ_lib$$,
+                    (SELECT ARRAY_AGG(id) FROM actor.org_unit_descendants($4))
+                )
+            )::query_int
+         )
 ';
+        END IF;
     ELSE
         opac_visibility_join := '';
     END IF;