# of transaction the ID refers to without having to query the DB.
# skip_no_fines - filter out transactions which will never be billed,
# e.g. circs with a $0 max fine or $0 recurring fine.
+#
+# parallel_count -- number of parallel processes handling these circs
+# parallel_slot -- which batch of parallel circs to process.
+# value is 1..$parallel_count
sub overdue_circs {
my $upper_interval = shift || '1 millennium';
my $idlist = shift;
my $partition = shift;
my $skip_no_fines = shift;
+ my $parallel_count = shift || 1;
+ my $parallel_slot = shift || 1;
# Only retrieve ID's in the initial query if that's all the caller needs.
my $contents = $idlist ? 'id' : '*';
my $fines_filter = $skip_no_fines ?
'AND recurring_fine <> 0 AND max_fine <> 0' : '';
+ my $id_filter = '';
+ if ($parallel_count > 1) {
+ $parallel_slot--; # translate to zero-based slot numbers
+ $id_filter = "AND MOD(id, $parallel_count) = $parallel_slot";
+ }
+
my $c_t = action::circulation->table;
my $sql = <<" SQL";
FROM $c_t
WHERE stop_fines IS NULL
$fines_filter
+ $id_filter
AND due_date < ( CURRENT_TIMESTAMP - grace_period )
AND fine_interval < ?::INTERVAL
SQL
push @circs, map { $idlist ? $_->{id} : booking::reservation->construct($_) } $sth->fetchall_hash;
+ $logger->info("parallel=$parallel_count slot=$parallel_slot ".
+ "processing ".scalar(@circs)." transactions");
+
return @circs;
}
my $self = shift;
my $client = shift;
my $circ_id = shift;
+ my $parallel_count = shift || 1;
+ my $parallel_slot = shift;
my $circs;
my $editor = new_editor;
$circs = $editor->search_booking_reservation->search_where( { id => $circ_id, return_time => undef, cancel_time => undef } );
}
} else {
- $circs = [overdue_circs(undef, 1, 1, 1)];
+ $circs =
+ [overdue_circs(undef, 1, 1, 1, $parallel_count, $parallel_slot)];
}
return OpenILS::Application::Circ::CircCommon->generate_fines({circs => $circs, conn => $client})
api_level => 1,
);
- my $storage = OpenSRF::AppSession->create("open-ils.storage");
- my $r = $storage->request('open-ils.storage.action.circulation.overdue.id_list');
- while (my $resp = $r->recv(timeout => 600)) {
- my $circ_id = $resp->content;
- $multi_generator->request( 'open-ils.storage.action.circulation.overdue.generate_fines', $circ_id );
+ for my $slot (1..$parallel) {
+ $multi_generator->request(
+ 'open-ils.storage.action.circulation.overdue.generate_fines',
+ undef, $parallel, $slot
+ );
}
- $storage->disconnect();
+
$multi_generator->session_wait(1);
$multi_generator->disconnect;
-
}
unlink $lockfile;