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
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try
builder.where().dueAfter(dNow)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Correct - from the GUI I can do a duedate < now() and see the issues that should show. From the code, nothing shows.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
print/log the where clause or query, and let us know what it says.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.