LP#1549505: Surface badge list and popularity in the result data
authorMike Rylander <mrylander@gmail.com>
Wed, 3 Feb 2016 17:26:53 +0000 (12:26 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 24 Feb 2016 22:38:47 +0000 (17:38 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm

index 1e6a485..b523e80 100644 (file)
@@ -1364,9 +1364,9 @@ sub staged_search {
 
             # Create backwards-compatible result structures
             if($IAmMetabib) {
-                $results = [map {[$_->{id}, $_->{rel}, $_->{record}]} @$results];
+                $results = [map {[$_->{id}, $_->{badges}, $_->{popularity}, $_->{rel}, $_->{record}]} @$results];
             } else {
-                $results = [map {[$_->{id}]} @$results];
+                $results = [map {[$_->{id}, $_->{badges}, $_->{popularity}]} @$results];
             }
 
             push @$new_ids, grep {defined($_)} map {$_->[0]} @$results;
index ecd1bad..1234177 100644 (file)
@@ -519,13 +519,15 @@ sub load_rresults {
         }
     }
 
-    if ($tag_circs) {
-        for my $rec (@{$ctx->{records}}) {
-            my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
-            # index 1 in the per-record result array is a boolean which
+    for my $rec (@{$ctx->{records}}) {
+        my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
+        $rec->{badges} = [split(',', $res_rec->[1])] if $res_rec->[1];
+        $rec->{popularity} = $res_rec->[2];
+        if ($tag_circs) {
+            # index 3 (5 for MR) in the per-record result array is a boolean which
             # indicates whether the record in question is in the users
             # accessible circ history list
-            my $index = $is_meta ? 3 : 1;
+            my $index = $is_meta ? 5 : 3;
             $rec->{user_circulated} = 1 if $res_rec->[$index];
         }
     }