my $self = shift;
my $client = shift;
my $granularity = shift;
+ my $granflag = shift;
my $query = [{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] }, 'join' => 'atevdef' }];
if (defined $granularity) {
- $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] };
+ if ($granflag) {
+ $query->[0]->{'+atevdef'} = {granularity => $granularity};
+ } else {
+ $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] };
+ }
} else {
$query->[0]->{'+atevdef'} = {granularity => undef};
}
my $self = shift;
my $client = shift;
my $granularity = shift;
+ my $granflag = shift;
- my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run($granularity);
+ my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run($granularity, $granflag);
my %groups = ( '*' => [] );
my $self = shift;
my $client = shift;
my $granularity = shift;
+ my $granflag = shift;
- my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run($granularity);
+ my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run($granularity, $granflag);
# Could report on how the "found" events were grouped, but who's going to
# consume that information?
my $opt_hooks;
my $opt_process_hooks = 0;
my $opt_granularity = undef;
+my $opt_gran_only = undef;
(-f $opt_custom_filter) or undef($opt_custom_filter); # discard default if no file exists
'run-pending' => \$opt_run_pending,
'hooks=s' => \$opt_hooks,
'granularity=s' => \$opt_granularity,
+ 'granularity-only' => \$opt_gran_only,
'process-hooks' => \$opt_process_hooks,
'debug-stdout' => \$opt_debug_stdout,
'custom-filters=s' => \$opt_custom_filter,
my $max_sleep = $opt_max_sleep;
+$opt_lockfile .= '.' . $opt_granularity if ($opt_granularity && $opt_gran_only);
+
# typical passive hook filters
my $hook_handlers = {
--granularity=<label>
Run events with {label} granularity setting, or no granularity setting
+ --granularity-only
+ Used in combination with --granularity, prevents the running of events with no granularity setting
+
--debug-stdout
Print server responses to stdout (as JSON) for debugging
sub run_pending {
$opt_verbose and print "run_pending: " .
- ($opt_run_pending ? ($opt_granularity || 'ALL granularity') : 'SKIPPING') . "\n";
+ ($opt_run_pending ?
+ ($opt_granularity ?
+ ( $opt_granularity . (
+ $opt_gran_only ?
+ ' ONLY' :
+ ' and NON-GRANULAR'
+ )
+ ) :
+ 'NON-GRANULAR'
+ ) :
+ 'SKIPPING'
+ ) . "\n";
+
return unless $opt_run_pending;
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
- my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity);
+ my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity => $opt_gran_only);
my $check_lockfile = 1;
while (my $resp = $req->recv(timeout => $req_timeout)) {