LP#1756142 Stream the reporter "schedule" retrieve-by-folder response
authorDan Wells <dbw2@calvin.edu>
Wed, 14 Mar 2018 22:34:31 +0000 (18:34 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 15 Mar 2018 17:44:27 +0000 (13:44 -0400)
One of the options in the reporter when viewing future and past
reports (aka a "schedule") is to retrieve "all", but this eventually
results in a massive return value which clogs the OpenSRF pipes (or,
rather, doesn't fit at all).

Let's set this to stream the responses, which appears to work fine
in the current reporter interface without any other changes.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Reporter.pm

index 897fb22..eb3bfb2 100644 (file)
@@ -131,7 +131,9 @@ sub retrieve_folder_data {
 
 __PACKAGE__->register_method(
     api_name => 'open-ils.reporter.schedule.retrieve_by_folder',
-    method => 'retrieve_schedules');
+    method => 'retrieve_schedules',
+    stream => 1
+);
 sub retrieve_schedules {
     my( $self, $conn, $auth, $folderId, $limit, $complete ) = @_;
     my $e = new_rstore_editor(authtoken=>$auth);
@@ -152,7 +154,12 @@ sub retrieve_schedules {
     $query->[0]->{complete_time} = undef unless $complete;
     $query->[0]->{complete_time} = { '!=' => undef } if $complete;
 
-    return $e->search_reporter_schedule($query);
+    my $schedules = $e->search_reporter_schedule($query);
+    foreach my $schedule (@$schedules) {
+        $conn->respond($schedule);
+    }
+
+    return undef;
 }
 
 __PACKAGE__->register_method(