1 package FS::part_event::Condition::once_every;
4 use FS::Record qw( qsearch );
8 use base qw( FS::part_event::Condition );
10 sub description { "Don't run this event more than once in the specified interval"; }
12 # Runs the event at most "once every X".
16 'run_delay' => { label=>'Interval', type=>'freq', value=>'1m', },
21 my($self, $object, %opt) = @_;
23 my $obj_pkey = $object->primary_key;
24 my $tablenum = $object->$obj_pkey();
26 my $max_date = $self->option_age_from('run_delay',$opt{'time'});
28 my @existing = qsearch( {
29 'table' => 'cust_event',
31 'eventpart' => $self->eventpart,
32 'tablenum' => $tablenum,
33 'status' => { op=>'!=', value=>'failed' },
34 '_date' => { op=>'>', value=>$max_date },
36 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
37 ? " AND eventnum != $1 "