4.2.13 rt-crontool search result oddities

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?

  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

  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

Hi Jeff,

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’”.

  1. 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

signature.asc (801 Bytes)