sub overdue_circs {
my $grace = shift;
my $upper_interval = shift || '1 millennium';
+ my $idlist = shift;
my $c_t = action::circulation->table;
my $sth = action::circulation->db_Main->prepare_cached($sql);
$sth->execute($upper_interval);
- my @circs = map { action::circulation->construct($_) } $sth->fetchall_hash;
+ my @circs = map { $idlist ? $_->{id} : action::circulation->construct($_) } $sth->fetchall_hash;
$c_t = booking::reservation->table;
$sql = <<" SQL";
$sth = action::circulation->db_Main->prepare_cached($sql);
$sth->execute();
- push @circs, map { booking::reservation->construct($_) } $sth->fetchall_hash;
+ push @circs, map { $idlist ? $_->{id} : booking::reservation->construct($_) } $sth->fetchall_hash;
return @circs;
}
my $client = shift;
my $grace = shift || '';
- $client->respond( $_->to_fieldmapper ) for ( overdue_circs($grace) );
+ my $idlist = $self->api_name =~/id_list/o ? 1 : 0;
+
+ $client->respond( $idlist ? $_ : $_->to_fieldmapper ) for ( overdue_circs($grace, '', $idlist) );
return undef;
stream => 1,
method => 'grab_overdue',
);
+__PACKAGE__->register_method(
+ api_name => 'open-ils.storage.action.circulation.overdue.id_list',
+ api_level => 1,
+ stream => 1,
+ method => 'grab_overdue',
+);
sub nearest_hold {
my $self = shift;
use warnings;
use OpenSRF::Utils::JSON;
use OpenSRF::System;
+use OpenSRF::Utils::SettingsClient;
+use OpenSRF::MultiSession;
my $config = shift || die "bootstrap config required\n";
my $lockfile = shift || "/tmp/generate_fines-LOCK";
close F;
OpenSRF::System->bootstrap_client( config_file => $config );
+my $settings = OpenSRF::Utils::SettingsClient->new;
+my $parallel = $settings->config_value( fine_generator => 'parallel' ) || 1;
-my $r = OpenSRF::AppSession
- ->create( 'open-ils.storage' )
- ->request( 'open-ils.storage.action.circulation.overdue.generate_fines' => $grace );
+if ($parallel == 1) {
-while (!$r->complete) { $r->recv };
+ my $r = OpenSRF::AppSession
+ ->create( 'open-ils.storage' )
+ ->request( 'open-ils.storage.action.circulation.overdue.generate_fines' => $grace );
+
+ while (!$r->complete) { $r->recv };
+
+} else {
+
+ my $multi_generator = OpenSRF::MultiSession->new(
+ app => 'open-ils.storage',
+ cap => $parallel,
+ api_level => 1,
+ );
+
+ my $storage = OpenSRF::AppSession->create("open-ils.storage");
+ my $r = $storage->request('open-ils.storage.action.circulation.overdue.id_list', $grace);
+ while (my $resp = $r->recv) {
+ my $circ_id = $resp->content;
+ $multi_generator->request( 'open-ils.storage.action.circulation.overdue.generate_fines', $grace, $circ_id );
+ }
+ $storage->disconnect();
+ $multi_generator->session_wait(1);
+ $multi_generator->disconnect;
+
+}
unlink $lockfile;