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

Ole André Vabø October 23, 2014

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
Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 24, 2014

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