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 vote

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,189 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot