[rt-devel] Problems using LimitXXX Statements

Bruce Campbell bruce_campbell at ripe.net
Thu Feb 7 13:58:44 EST 2002


On Tue, 29 Jan 2002, Julian Hein wrote:

> 2) The second thing was a script the should be run by cron and send a
> mail to every user owning at ticket with a due date of today. I modified
> tickets to very date one could think of and user all operators (=><) but
> i allways got the same tickets or no ticket. Any ideas?
>
> my $tickets = new RT::Tickets($RT::SystemUser);
> $tickets->LimitStatus(VALUE => 'open');
> $tickets->LimitStatus(VALUE => 'new');
> $tickets->LimitStatus(VALUE => 'stalled');
> $tickets->LimitDate(FIELD => 'Due', OPERATOR => '=', VALUE => $now);

Ah.  The 'Due' column is datetime.  So your script will happily match
anything thats 'Due' that very second (ignoring that $now should be
$now->ISO).  This is possibly not what you want.

Assuming that you run this script once per day, you should be able to:

	my $yesterday = $now;
	$yesterday->AddDays(-1);
	$tickets->LimitDate(FIELD => 'Due',
		OPERATOR => '>=',
		VALUE => $yesterday->ISO,
		ENTRYAGGREGATOR => 'AND' );
	$tickets->LimitDate(FIELD => 'Due',
		OPERATOR => '<=',
		VALUE => $now->ISO,
		ENTRYAGGREGATOR => 'AND' );

That will match anything due within the last 24hrs, and it should be
simple to change it to match anything due within the next 24 hours as
well.

Regards,

-- 
                             Bruce Campbell                            RIPE
                   Systems/Network Engineer                             NCC
                 www.ripe.net - PGP562C8B1B                      Operations






More information about the Rt-devel mailing list