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

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 ?

0 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

851 views 3 12
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