LP1889694 copy count batch mode (revert)
authorBill Erickson <berickxx@gmail.com>
Fri, 31 Jul 2020 14:00:17 +0000 (10:00 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 31 Jul 2020 14:00:17 +0000 (10:00 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index 159ecd7..870c4eb 100644 (file)
@@ -276,6 +276,66 @@ sub record_id_to_copy_count {
     return [ sort { $a->{depth} <=> $b->{depth} } @count ];
 }
 
+
+__PACKAGE__->register_method(
+    method   => "record_id_to_copy_count_batch",
+    api_name => "open-ils.search.biblio.record.copy_count.batch",
+    stream   => 1,
+    signature => {
+        desc => q/Returns a stream of copy summaries for a set of records 
+                for the context org unit and all ancestor org units/,
+        params => [
+            {desc => 'Context org unit id', type => 'number'},
+            {desc => 'Record IDs', type => 'array'}
+        ],
+        return => {
+            desc => q/
+                Returns a stream of objects with 2 keys:
+                    record: record id,
+                    counts: see open-ils.search.biblio.record.copy_count
+                /,
+            type => 'object'
+        }
+    }
+);
+
+__PACKAGE__->register_method(
+    method   => "record_id_to_copy_count_batch",
+    api_name => "open-ils.search.biblio.record.copy_count.batch.staff",
+    stream   => 1,
+    signature => 'see open-ils.search.biblio.record.copy_count.batch'
+    
+);
+
+__PACKAGE__->register_method(
+    method   => "record_id_to_copy_count_batch",
+    api_name => "open-ils.search.biblio.metarecord.copy_count.batch",
+    stream   => 1,
+    signature => 'see open-ils.search.biblio.record.copy_count.batch'
+);
+
+__PACKAGE__->register_method(
+    method   => "record_id_to_copy_count_batch",
+    api_name => "open-ils.search.biblio.metarecord.copy_count.batch.staff",
+    stream   => 1,
+    signature => 'see open-ils.search.biblio.record.copy_count.batch'
+);
+
+
+sub record_id_to_copy_count_batch {
+    my ($self, $client, $org_id, $record_ids) = @_;
+
+    for my $rec_id (@$record_ids) {
+        $client->respond({
+            record => $rec_id, 
+            counts => record_id_to_copy_count($self, $client, $org_id, $rec_id)
+        });
+    }
+
+    return undef;
+}
+
+
 __PACKAGE__->register_method(
     method   => "record_has_holdable_copy",
     api_name => "open-ils.search.biblio.record.has_holdable_copy",