Do not exclude "identifier" facets by default
authorBill Erickson <berick@esilibrary.com>
Thu, 5 Jan 2012 18:18:29 +0000 (13:18 -0500)
committerMike Rylander <mrylander@gmail.com>
Tue, 20 Mar 2012 16:32:33 +0000 (12:32 -0400)
No longer ignore "identifier" fields when collecting and caching
facet data.  This change causes all config.metabib_field's that are
marked as facet_fields to be taken into consideration.

Apart from marking a field as facet_field=false, it's also possible to
control which fields are visible within the jspac and tpac (pending LP
911908)

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

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

index 6368787..189ec6c 100644 (file)
@@ -1477,10 +1477,6 @@ sub cache_facets {
     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
@@ -1494,29 +1490,33 @@ sub cache_facets {
     #   group by 1,2;
 
     my $count_field = $metabib ? 'metarecord' : 'source';
-    my $facets = $U->cstorereq( "open-ils.cstore.json_query.atomic",
-        {   select  => {
-                mfae => [ { column => 'field', alias => 'id'}, 'value' ],
-                mmrsm => [{
-                    transform => 'count',
-                    distinct => 1,
-                    column => $count_field,
-                    alias => 'count',
-                    aggregate => 1
-                }]
-            },
-            from    => {
-                mfae => {
-                    mmrsm => { field => 'source', fkey => 'source' },
-                    cmf   => { field => 'id', fkey => 'field' }
-                }
-            },
-            where   => {
-                '+mmrsm' => { $count_field => $results },
-                '+cmf'   => { field_class => { 'not in' => $ignore }, facet_field => 't' }
+    my $query = {   
+        select  => {
+            mfae => [ { column => 'field', alias => 'id'}, 'value' ],
+            mmrsm => [{
+                transform => 'count',
+                distinct => 1,
+                column => $count_field,
+                alias => 'count',
+                aggregate => 1
+            }]
+        },
+        from    => {
+            mfae => {
+                mmrsm => { field => 'source', fkey => 'source' },
+                cmf   => { field => 'id', fkey => 'field' }
             }
+        },
+        where   => {
+            '+mmrsm' => { $count_field => $results },
+            '+cmf'   => { facet_field => 't' }
         }
-    );
+    };
+
+    $query->{where}->{'+cmf'}->{field_class} = {'not in' => $ignore}
+        if ref($ignore) and @$ignore > 0;
+
+    my $facets = $U->cstorereq("open-ils.cstore.json_query.atomic", $query);
 
     for my $facet (@$facets) {
         next unless ($facet->{value});