LP#1746800: Option to exclude empty bibs in staff searches user/miker/lp-1746800-exclude_empty_bibs_option
authorMike Rylander <mrylander@gmail.com>
Fri, 4 Feb 2022 16:13:56 +0000 (11:13 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 4 Feb 2022 16:13:56 +0000 (11:13 -0500)
This commit adds a search modifier of #exclude_empty that tells
Evergreen to exclude empty bibs.  This option is only useful in staff
searches, either via the #staff modifier or the .staff variant of the
search API.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index c4e3455..179e933 100644 (file)
@@ -718,6 +718,7 @@ __PACKAGE__->add_search_filter( 'superpage_size' );
 __PACKAGE__->add_search_filter( 'estimation_strategy' );
 __PACKAGE__->add_search_filter( 'from_metarecord' );
 __PACKAGE__->add_search_modifier( 'available' );
+__PACKAGE__->add_search_modifier( 'exclude_empty' );
 __PACKAGE__->add_search_modifier( 'staff' );
 __PACKAGE__->add_search_modifier( 'deleted' );
 __PACKAGE__->add_search_modifier( 'lucky' );
@@ -1057,7 +1058,7 @@ sub toSQL {
         $final_c_attr_test = 'EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source AND vis_attr_vector @@ c_attr.vis_test)';
     }
  
-    if ($self->find_modifier('staff')) { # staff search
+    if ($self->find_modifier('staff') && !$self->find_modifier('exclude_empty')) { # staff search, and exclude_empty was not requested
         $final_c_attr_test ||= 'FALSE';
         $final_c_attr_test = '(' . $final_c_attr_test . " OR (" .
                 "NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) " .