[open-ils-commits] r14769 - in tags/rel_1_6_0_0/Open-ILS: examples src/perlmods/OpenILS/Application src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 4 14:35:28 EST 2009
Author: miker
Date: 2009-11-04 14:35:24 -0500 (Wed, 04 Nov 2009)
New Revision: 14769
Modified:
tags/rel_1_6_0_0/Open-ILS/examples/fm_IDL.xml
tags/rel_1_6_0_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
Log:
add max_delay field to optionally pre-invalidate events based on a delay window, instead of simply the minimum delay time
Modified: tags/rel_1_6_0_0/Open-ILS/examples/fm_IDL.xml
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/examples/fm_IDL.xml 2009-11-04 19:32:28 UTC (rev 14768)
+++ tags/rel_1_6_0_0/Open-ILS/examples/fm_IDL.xml 2009-11-04 19:35:24 UTC (rev 14769)
@@ -647,6 +647,7 @@
<field reporter:label="Success Cleanup" name="cleanup_success" reporter:datatype="link"/>
<field reporter:label="Failure Cleanup" name="cleanup_failure" reporter:datatype="link"/>
<field reporter:label="Processing Delay" name="delay" reporter:datatype="interval"/>
+ <field reporter:label="Max Event Validity Delay" name="max_delay" reporter:datatype="interval"/>
<field reporter:label="Processing Delay Context Field" name="delay_field" reporter:datatype="text"/>
<field reporter:label="Processing Group Context Field" name="group_field" reporter:datatype="text"/>
<field reporter:label="Template" name="template" reporter:datatype="text"/>
Modified: tags/rel_1_6_0_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2009-11-04 19:32:28 UTC (rev 14768)
+++ tags/rel_1_6_0_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2009-11-04 19:35:24 UTC (rev 14769)
@@ -359,7 +359,13 @@
{ hook => [ keys %hook_hash ], active => 't' },
);
- my $first_loop = 1;
+ my $orig_filter_and = [];
+ if ($$filter{'-and'}) {
+ for my $f ( @{ $$filter{'-and'} } ) {
+ push @$orig_filter_and, $f;
+ }
+ }
+
for my $def ( @$defs ) {
my $date = DateTime->now->subtract( seconds => interval_to_seconds($def->delay) );
@@ -381,23 +387,27 @@
->add( seconds => interval_to_seconds($def->delay) )
->strftime( '%F %T%z' );
} else {
- $filter->{ $def->delay_field } = {
- '<=' => DateTime
- ->now
- ->subtract( seconds => interval_to_seconds($def->delay) )
- ->strftime( '%F %T%z' )
- };
+ if ($def->max_delay) {
+ my @times = sort {$a <=> $b} interval_to_seconds($def->delay), interval_to_seconds($def->max_delay);
+ $filter->{ $def->delay_field } = {
+ 'between' => [
+ DateTime->now->subtract( seconds => $times[0] )->strftime( '%F %T%z' ),
+ DateTime->now->subtract( seconds => $times[1] )->strftime( '%F %T%z' )
+ ]
+ };
+ } else {
+ $filter->{ $def->delay_field } = {
+ '<=' => DateTime->now->subtract( seconds => interval_to_seconds($def->delay) )->strftime( '%F %T%z' )
+ };
+ }
}
my $class = _fm_class_by_hint($hook_hash{$def->hook}->core_type);
# filter where this target has an event (and it's pending, for active hooks)
- if($first_loop) {
- $$filter{'-and'} = [] if (!exists($$filter{'-and'}));
- $first_loop = 0;
- } else {
- # remove the pre-existing event check for the previous event def
- pop @{ $filter->{'-and'} };
+ $$filter{'-and'} = [];
+ for my $f ( @$orig_filter_and ) {
+ push @{ $$filter{'-and'} }, $f;
}
push @{ $filter->{'-and'} }, {
Modified: tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql 2009-11-04 19:32:28 UTC (rev 14768)
+++ tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql 2009-11-04 19:35:24 UTC (rev 14769)
@@ -110,6 +110,7 @@
cleanup_success TEXT REFERENCES action_trigger.cleanup (module) DEFERRABLE INITIALLY DEFERRED,
cleanup_failure TEXT REFERENCES action_trigger.cleanup (module) DEFERRABLE INITIALLY DEFERRED,
delay INTERVAL NOT NULL DEFAULT '5 minutes',
+ max_delay INTERVAL,
delay_field TEXT, -- for instance, xact_start on a circ hook ... look for fields on hook.core_type where datatype=timestamp? If not set, delay from now()
group_field TEXT, -- field from this.hook.core_type to batch event targets together on, fed into reactor a group at a time.
template TEXT, -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified.
More information about the open-ils-commits
mailing list