How to query issues with empty workLogged?

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
Accepted answer

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
    }
}

Hi Michal,

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

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.

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,376 views 15 19
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you