We have a number of duplicate components in our project and some that are just named incorrectly, so I wrote a program to fix these issues.
The problem is I don't want to delete a component if it's associated with Issues. I want to move it to a different component, which I do using the appropriate API call.
To find out if a component is being used by any issues I call the following to get all components for our project:
/rest/api/latest/project/{key}/components
I would then loop through those components and call the following to get all related issues for each component:
/rest/api/latest/component/{id}/relatedIssueCounts
However, this is incredibly slow and it makes a lot of calls to the REST API. 165+, so far.
It would be nice if the call to return all components for a project could include the relatedIssueCount as a JSON property. Maybe it does, but I didn't see it.
Anyhow, is there a better way to do it than I'm currently doing it?
Since you probably know which components you wan to process, I would attempt to search for issues with those components using JQL through the REST API /rest/api/2/search.
Thanks. I tried what you suggested, but it takes just as long. I guess there's no better way. They really need to just change the /rest/api/latest/project/{key}/components JSON to include the relatedIssueCounts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How many issues do you have? It really should not be that slow. I am assuming you are using maxresults and startwith parameters so you can get back a large set of issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would also turn off validate JQL as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe your real issue is the JIRA Cloud. Does the JQL run slowly through the JIRA UI?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not really about issues per say since the only thing I query concerning issues is a count per component using /rest/api/latest/component/{id}/relatedIssueCounts. We have around 165 components and querying those using /rest/api/latest/project/{key}/components takes about 1.5-2 seconds. Looping through those 165 components to determine if they are assigned to issues takes just shy of a minute. It's not horrible, but if the /rest/api/latest/project/{key}/components call already returned that data then I suspect the total cal would be no more than 5 seconds. The cloud searches run fine, but there's really no way to determine what I want in the cloud search. Anyways, it's no big deal that it takes around a minute total to get the data. I was just hoping the /rest/api/latest/project/{key}/components call returned more info/data so my code would be more efficient.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.