Is it possible to return list of issues where component count = x?

I have a list of issues that are connected to spesific components. Most are connected to several components, and sometimes the connection is wrong. Before changing or removing the component link, I need to know if the issues will still have a component connection if I remove a spesific connection. 

So what I need is someting like this: 

Project = xxx And Issuetype = xxx and component = xxx and Component.Count = 1.

 

Is this in any way possible with JQL?

1 answer

0 votes

Hi Ole,

It isn't possible to do this by default in JIRA using JQL, but you can do this by running the following query in your database:

SELECT p.pkey, ji.issuenum FROM component c
    JOIN nodeassociation na ON na.sink_node_id = c.id
    JOIN jiraissue ji ON ji.id = na.source_node_id
    JOIN project p on p.id = ji.project
    JOIN issuetype it ON it.id = ji.issuetype
WHERE na.sink_node_entity = 'Component'
    AND na.source_node_entity = 'Issue'
    AND c.cname IN ('COMP-NAME')
    AND p.pkey = 'PROJECT-KEY'
    AND it.pname = 'ISSUE-TYPE'
    AND ji.id IN 
        (SELECT ji.id FROM component c
            JOIN nodeassociation na ON na.sink_node_id = c.id
            JOIN jiraissue ji ON ji.id = na.source_node_id
            JOIN project p on p.id = ji.project
        WHERE na.sink_node_entity = 'Component'
            AND na.source_node_entity = 'Issue'
        GROUP BY ji.id
        HAVING count(c.id) > X)
ORDER BY 2;

You just need to replace:

  • 'COMP-NAME' with the actual name of the component
  • PROJECT-KEY with the key of the project
  • 'ISSUE-TYPE' with the name of the issue type and 
  • X with the number of components

I know this is a big query, but I hope it helps. smile

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

27,012 views 2 7
Join discussion

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