Querying JIRA to Produce Counts of Issues by Different Type
Asked Answered
W

1

9

Suppose I have the following JIRA filter.

project = XXX AND resolution = Unresolved AND assignee in (EMPTY) ORDER BY Type asc, priority desc

I use it to see all unassigned issues in a certain project and pull from for triage.

Every now-and-then, I need to know how many are in each Type, i.e., I actually want a count for each.

How could I modify this query to do that or write a new one that accomplishes the same thing?

Wagoner answered 31/1, 2019 at 16:38 Comment(0)
S
10

Remember that JQL isn't SQL - it just operates on tickets and returns lists of them for other parts of JIRA to consume, and doesn't really have a mechanism for counting results.

That said, you can use the JIRA REST API's /search endpoint along with maxResults=0 to construct JQL queries for each Type you care about, and the endpoint will give you a total value for that ticket Type:

https://jira.url/rest/api/latest/search?jql=project%20=%20XXX%20AND%20resolution%20=%20Unresolved%20AND%20assignee%20in%20%28EMPTY%29%20AND%20Type%20=%20Task&maxResults=0

Results in this output for Type=Task:

{
    "startAt":0,
    "maxResults":0,
    "total":123,
    "issues":[]
}
Stefaniastefanie answered 1/2, 2019 at 0:5 Comment(2)
Much appreciated. Do you know if JIRA allows one to monitor statistics on such things? That is, is there a page that could plot trends for these quantities or do I need to invent one myself and query these end-points?Wagoner
Yeah - you'll need to make your JQL query into a Filter. Then, create a JIRA Dashboard, add the "Issue Statistics" gadget to it, and set the gadget's "Statistic Type" to "Issue Type" and choose your Filter to use as the gadget's basis.Stefaniastefanie

© 2022 - 2024 — McMap. All rights reserved.