JBAS-1929 Browse mattype filter see link counts
authorBill Erickson <berickxx@gmail.com>
Wed, 10 Jan 2018 19:26:23 +0000 (14:26 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm

index 6bbdd20..c3f0a59 100644 (file)
@@ -174,7 +174,7 @@ sub find_authority_headings_and_notes {
 }
 
 sub map_authority_headings_to_results {
-    my ($self, $linked, $results, $auth_ids, $authority_field_name) = @_;
+    my ($self, $linked, $results, $auth_ids, $authority_field_name, @params) = @_;
 
     # Use the linked authority records' control sets to find and pick
     # out non-main-entry headings. Build the headings and make a
@@ -191,6 +191,20 @@ sub map_authority_headings_to_results {
         ];
     }
 
+    my $abl_join = {};
+    if (my $mattype = $params[7]) { # KCLS JBAS-1929
+        $abl_join = {
+            mraf => {
+                field => 'id',
+                fkey => 'bib',
+                filter => {
+                    attr => 'mattype',
+                    value => $mattype
+                }
+            }
+        };
+    }
+
     # Get linked-bib counts for each of those authorities, and put THAT
     # information into place in the data structure.
     my $counts = $self->editor->json_query({
@@ -201,7 +215,7 @@ sub map_authority_headings_to_results {
                 "authority"
             ]
         },
-        from => {abl => {}},
+        from => {abl => $abl_join},
         where => {
             "+abl" => {
                 authority => [
@@ -237,7 +251,7 @@ sub map_authority_headings_to_results {
 # case $self->editor->event should always point to the reason for failure).
 # $results must be an arrayref of result rows from the DB's metabib.browse()
 sub flesh_browse_results {
-    my ($self, $results) = @_;
+    my ($self, $results, @params) = @_;
 
     for my $authority_field_name ( qw/authorities sees/ ) {
         for my $r (@$results) {
@@ -274,7 +288,8 @@ sub flesh_browse_results {
                 where => {"+are" => {id => \@auth_ids}}
             }) or return;
 
-            $self->map_authority_headings_to_results($linked, $results, \@auth_ids, $authority_field_name);
+            $self->map_authority_headings_to_results(
+                $linked, $results, \@auth_ids, $authority_field_name, @params);
         }
     }
 
@@ -296,7 +311,7 @@ sub load_browse_impl {
         $self->ctx->{browse_error} = 1;
 
         return;
-    } elsif (not $self->flesh_browse_results($results)) {
+    } elsif (not $self->flesh_browse_results($results, @params)) {
         $logger->warn(
             "error in browse (flesh): " . $self->editor->event->{textcode}
         );