Allow caller to ignore selected facet classes; ignore identifier class by default
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Oct 2010 00:40:44 +0000 (00:40 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Oct 2010 00:40:44 +0000 (00:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18141 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm

index 7dad749..96ca5d2 100644 (file)
@@ -1108,6 +1108,7 @@ sub staged_search {
     my $search_duration;
     my $user_offset = $search_hash->{offset} ||  0; # user-specified offset
     my $user_limit  = $search_hash->{limit}  || 10;
+    my $ignore_facet_classes  = $search_hash->{ignore_facet_classes};
     $user_offset = ($user_offset >= 0) ? $user_offset :  0;
     $user_limit  = ($user_limit  >= 0) ? $user_limit  : 10;
 
@@ -1262,7 +1263,7 @@ sub staged_search {
         }
     );
 
-    cache_facets($facet_key, $new_ids, $IAmMetabib) if $docache;
+    cache_facets($facet_key, $new_ids, $IAmMetabib, $ignore_facet_classes) if $docache;
 
     return undef;
 }
@@ -1368,10 +1369,14 @@ __PACKAGE__->register_method(
 
 sub cache_facets {
     # add facets for this search to the facet cache
-    my($key, $results, $metabib) = @_;
+    my($key, $results, $metabib, $ignore) = @_;
     my $data = $cache->get_cache($key);
     $data ||= {};
 
+    if (!ref($ignore)) {
+        $ignore = ['identifier']; # ignore the identifier class by default
+    }
+
     return undef unless (@$results);
 
     # The query we're constructing
@@ -1398,11 +1403,13 @@ sub cache_facets {
             },
             from    => {
                 mfae => {
-                    mmrsm => { field => 'source', fkey => 'source' }
+                    mmrsm => { field => 'source', fkey => 'source' },
+                    cmf   => { field => 'id', fkey => 'field' }
                 }
             },
             where   => {
-                '+mmrsm' => { $count_field => $results }
+                '+mmrsm' => { $count_field => $results },
+                '+cmf'   => { field_class => { 'not in' => $ignore } }
             }
         }
     );