[rt-users] 4.2.13 rt-crontool search result oddities

Shawn M Moore shawn at bestpractical.com
Tue Aug 9 11:47:33 EDT 2016


Hi Jeff,

> On Aug 8, 2016, at 23:29, Jeff Blaine <jblaine at kickflop.net> wrote:
> 
> I've just started exploring rt-crontool after many years of RT use, and
> the following results, per the queries, don't make any sense to me. Can
> someone point out what I am doing wrong?

If you do the same searches in the web UI, can you confirm that you see the same oddities? I don't think there's anything specific to rt-crontool that's changing how search works.

> 1. Owner nobody, status new, created more than 2 days ago
> 
>   /rt/bin/rt-crontool --search RT::Search::FromSQL --search-arg "Owner
> = 'Nobody' AND Status = 'new' AND Created > '2 days ago'" --action
> RT::Action --verbose
> 
>   Does not match this ticket, but should:
> 
>   Status: 	new
>   Owner: 	Nobody in particular
>   Created: 	Wed Jan 20 12:12:53 2016

The way RT interprets the "Created > '2 days ago'" clause is first is it translates the relative "2 days ago" into an absolute date. As of this writing, something like "2016-08-07 11:40:00". Then, it compares each ticket's created date to that date. So it's really searching for tickets whose Created date is after 2016-08-07 11:40:00. Your ticket was created well before August 7, so it's not matching.

In other words, RT is comparing timestamps, not durations. We just so happen to handle a duration in the right-hand side of a search clause by converting it to a timestamp. This is a useful feature for saved searches (and rt-crontool) in particular, since you don't want to always be updating the search terms to reflect the passage of time.

The good news is I think you'll achieve what you want by flipping the operator, so "Created <= '2 days ago'", which RT interprets as "Created <= '2016-08-07 11:40:00'", which means "tickets created at or before 2016-08-07 11:40:00", which is what you'd meant by "Created > '2 days ago'".

> 2. Owner nobody, status new, created less than 90 days ago
> 
>   /rt/bin/rt-crontool --search RT::Search::FromSQL --search-arg "Owner
> = 'Nobody' AND Status = 'new' AND Created < '90 days ago'" --action
> RT::Action --verbose
> 
>   Matches this ticket, but should not:
> 
>   Status: 	new
>   Owner: 	Nobody in particular
>   Created: 	Mon Apr 07 12:18:30 2014

Same story. This is searching for all tickets whose Created date is before 2016-05-11 11:40:00 or thereabouts. Created >= '90 days ago' should work better.

Best,
Shawn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20160809/56d053c9/attachment.sig>


More information about the rt-users mailing list