);
+__PACKAGE__->register_method(
+ method => 'users_of_interest',
+ api_name => 'open-ils.collections.users_of_interest.retrieve.atomic',
+ stream => 1,
+);
+
sub users_of_interest {
my( $self, $conn, $auth, $age, $fine_level, $location ) = @_;
+ my $atomic = $self->api_name =~ /atomic/;
+
return OpenILS::Event->new('BAD_PARAMS')
unless ($auth and $age and $fine_level and $location);
# they need global perms to view users so no org is provided
return $e->event unless $e->allowed('VIEW_USER');
- my $data = $U->storagereq(
- 'open-ils.storage.money.collections.users_of_interest.atomic',
- $age, $fine_level, $location);
-
- return [] unless $data and @$data;
-
- for (@$data) {
- my $u = $e->retrieve_actor_user(
- [
- $_->{usr},
- {
- flesh => 1,
- flesh_fields => {au => ["groups","profile", "card"]},
- select => {au => ["profile","id","dob", "card"]}
- }
- ]
- ) or return $e->event;
-
- $_->{usr} = {
- id => $u->id,
- dob => $u->dob,
- profile => $u->profile->name,
- barcode => $u->card->barcode,
- groups => [ map { $_->name } @{$u->groups} ],
- };
- }
-
- return $data;
+ my $data = [];
+
+ my $ses = OpenSRF::AppSession->create('open-ils.storage');
+ my $req = $ses->request(
+ 'open-ils.storage.money.collections.users_of_interest',
+ $age, $fine_level, $location);
+
+ # let the client know we're still here
+ $conn->status( new OpenSRF::DomainObject::oilsContinueStatus );
+
+ while( my $resp = $req->recv(timeout => 600) ) {
+ return $req->failed if $req->failed;
+ my $hash = $resp->content;
+ next unless $hash;
+
+ my $u = $e->retrieve_actor_user(
+ [
+ $hash->{usr},
+ {
+ flesh => 1,
+ flesh_fields => {au => ["groups","profile", "card"]},
+ #select => {au => ["profile","id","dob", "card"]}
+ }
+ ]
+ ) or return $e->event;
+
+ $hash->{usr} = {
+ id => $u->id,
+ dob => $u->dob,
+ profile => $u->profile->name,
+ barcode => $u->card->barcode,
+ groups => [ map { $_->name } @{$u->groups} ],
+ };
+
+ $conn->respond($hash);
+ }
+
+ return undef;
}