Need help finding past due issue in Listener

Scott Evans March 26, 2013

I am having trouble with finding past due issues in my Listener. I know that the JQL is duedate < now(). I have translated this to the following in my Listener:

Date dNow = new Date();
def jqlQueryParser = cm.getComponentInstanceOfType(JqlQueryParser.class) as JqlQueryParser
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder()
builder.where().due().lt(dNow)

The query doesn't find any issues ( I know there are 3). I think I am having trouble with the dNow Date format but can't figure it out. What am I doing wrong?

George

2 answers

1 accepted

0 votes
Answer accepted
Scott Evans March 26, 2013

I figured it out:

builder.where().due().lt("0d")

Since I want to find due date before today, I can search for due < 0d.

George

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2013

Awesome. Seems it is expecting worklog format and not actual date. I was going to suggest parsing JQL String. That can be another option for more complex queries like finding issues due before startOfDay.

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2013

Try

builder.where().dueAfter(dNow)

Scott Evans March 26, 2013

Nope - still see no issues.

TST-1 was due on 2013-03-05 00:00:00.0 <- issue.getDueDate().toString()

dNow.toString is Tue Mar 26 15:14:09 CDT 2013

It should have caught TST-1

Scott Evans March 26, 2013

Logically I'm not sure that made sense. Find issues that are due after now?

Anyways, I also setup a date of 1970 and tried to use .dueBetween(d1970, dNow) and still get no results. If I change my query to .project("TST") it finds results, so it's not anything else in my code.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2013

I am sorry, I meant dueBefore, which dioesn't exist. I would have asked you to try dueBetween as you tried but seems it is not working either!

Quick question, are you able to find it from UI? Is it not working only via code?

Scott Evans March 26, 2013

Correct - from the GUI I can do a duedate < now() and see the issues that should show. From the code, nothing shows.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2013

print/log the where clause or query, and let us know what it says.

Scott Evans March 26, 2013

Here is what the code is at:

Date oldDate = new Date();
            oldDate.setTime((long) 1);
            Date dNow = new Date();
            
            def jqlQueryParser = cm.getComponentInstanceOfType(JqlQueryParser.class) as JqlQueryParser
            JqlQueryBuilder builder = JqlQueryBuilder.newBuilder()
            builder.where().dueBetween(oldDate,dNow)

            Query query = builder.buildQuery()
            SearchService searchService = cm.getInstance().getSearchService();
            def qry_results = searchService.search(jadmin_user, query, PagerFilter.getUnlimitedFilter())
            
            def whereClause = query.getWhereClause()
            log.debug "where clause: " + whereClause.toString()

The debug statement prints:

where clause: {due >= "1969-12-31 18:00"} AND {due <= "2013-03-26 20:44"}

Suggest an answer

Log in or Sign up to answer