How to query issues with empty workLogged?

Michał Gawlik June 20, 2016

The query below works, but it doesn't include logged time for sub-tasks, so when there isn't logged time for issue but there are there is logged time for at least for one sub task, the issue is still the query result.  

issueFunction not in workLogged("after 2013/09/01 before 2020/09/30")

I would like the case when the time is logged to at least one sub task, the issue won't appear in the result set. Is it possible?

3 answers

1 accepted

2 votes
Answer accepted
sithera August 8, 2016

You can write your own JQL function which extends workLogged() function that it additionally returns issues with empty logged time which at least one sub-task have logged time.

 

String jqlQuery = "issueFunction in workLogged(\"" + operand.getArgs().get(0) + "\")";
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlQuery);

if (parseResult.isValid()){
    Query query = parseResult.getQuery();
    try {
        SearchResults results = searchService.search(user, query, PagerFilter.getUnlimitedFilter());
        List<Issue> issues = results.getIssues();

        for (Issue issue: issues){
            literals.add(new QueryLiteral(operand, issue.getId()));

            if (issue.isSubTask()){
                literals.add(new QueryLiteral(operand, issue.getParentId()));
            }
        }

    } catch (SearchException e) {
        // Catch exception
    }
}
0 votes
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.
June 21, 2016

This is pretty tricky. Although I'm kind of fatigued at the moment so I might be missing something.

The problem is that you want to query on the worklog index, but you return results from the issue index. Perhaps you can use the above query with another query that uses childrenOf ("your jql") to find issues that have no log worked on the parent but does have work logged on the children.

 

0 votes
Chander Inguva
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.
June 20, 2016

Hi Michal,

              When you use not in worklogged, why do you get Sub-tasks with logged time ?

Suggest an answer

Log in or Sign up to answer