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}/componentsI would then loop through those components and call the following to get all related issues for each component:
/rest/api/latest/component/{id}/relatedIssueCountsHowever, 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?