Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get count of issues for each priority?

intuit_pswadi April 23, 2013

In browser, for each project, there is a nice dashboard which shows graphically count of issues by priority, by assigny, by component. I want to build a mobile dashboard that will show similar information. However I did not see a REST API call that will return just the counts for results.

Is it possible to make a rest call e.g. like this

https://jira.atlassian.com/rest/api/2/search?jql=project%3d=10240+group+by+issuetype

which returns data like

{

[

"issueid" : 1,

"count" : 3

],

[

"issueid" : 2,

"count" : 9

],

[

"issueid" : 3,

"count" : 10

],

[

"issueid" : 4,

"count" : 30

],

}

I know I can make a REST API call for each issue type with maxResults=0 to just get the count, but that increases the number of calls I have to make for each aggregation. :-(

Any ideas?

Thanks,

Praveen

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2013

I used Google Chrome, Inspect Element, Network to see what that gadget calls and saw

https://jira.example.com:8443/rest/gadget/1.0/stats/generate.json?projectOrFilterId=project-10462&statType=issuetype&includeResolvedIssues=true&sortDirection=desc&sortBy=total

which when authenticated produces

{
rows: [
{
html: Task
count: 8
percentage: 50
classes: [
gadget_image
]
}
{
html: Helpdesk Request
count: 3
percentage: 19
classes: [
gadget_image
]
}
{
html: User Support
count: 2
percentage: 13
classes: [
gadget_image
]
}
{
html: Account Request
count: 1
percentage: 6
classes: [
gadget_image
]
}
{
html: Report Request
count: 1
percentage: 6
classes: [
gadget_image
]
}
{
html: Defect
count: 1
percentage: 6
classes: [
gadget_image
]
}
]
filterOrProjectName: Business Operations and Analytics
statTypeDescription: Issue Type
filterOrProjectLink: https://jira.example.com:8443/secure/IssueNavigator.jspa?reset=true&mode=hide&jqlQuery=project+%3D+BIZOPS
totalIssueCount: 16
}

intuit_pswadi April 23, 2013

Hi Matt,

Thanks! Those are great pointers. From the example you gave, could you give the correct URL for https://jira.atlassian.com/browse/JRA#selectedTab=com.atlassian.jira.plugin.system.project%3Aissues-panel where it is showing unresolved by priority, unresolved per components etc? I tried https://jira.atlassian.com/rest/gadget/1.0/stats/generate.json?projectOrFilterId=JRA&statType=issuetype&includeResolvedIssues=true&sortDirection=desc&sortBy=total but gives me error saying invalid projectOrFilterId. (I get the same error for my jira instance too)

BTW, from browser, actually it is making one call that gives the HTML for all those mini dashboards and thats what I see being returned in HTML. Could not find the generate JSON

Thanks again,

Praveen

0 votes
intuit_pswadi April 23, 2013

Actually I got it working.

https://jira.atlassian.com/rest/api/2/project/JRA gives the id 10240 Using that in the url you had given

https://jira.atlassian.com/rest/gadget/1.0/stats/generate.json?projectOrFilterId=project-10240&statType=issuetype&includeResolvedIssues=true&sortDirection=desc&sortBy=total gives me the content I was looking for.

Almost there! Now only if that json also returned issuetype id etc in the JSON, then I can really use the API. :-) Problem is the html contains info about type of issue etc. So my code can't be generic. Still, pretty useful.


Thanks,

Praveen

Daniel Sagayaraj August 6, 2017

From this URL i could understand that "statType=issuetype" makes the result to group by issueType, Any idea how we can have the group by count by jira status instead of issuetype?

0 votes
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2013

You can also use the REST API Browser that comes with the Developer Toolkit plugin to experiment with this

0 votes
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2013

You could start with the gadget definition in ./jira-project/jira-components/jira-plugins/jira-gadgets-plugin/src/main/resources/gadgets/stats-gadget.xml which seems to call

url: "/rest/gadget/1.0/stats/generate",

data: {

projectOrFilterId : gadgets.util.unescapeString(this.getPref("projectOrFilterId")),

statType: gadgets.util.unescapeString(this.getPref("statType")),

includeResolvedIssues: gadgets.util.unescapeString(this.getPref("includeResolvedIssues")),

sortDirection: gadgets.util.unescapeString(this.getPref("sortDirection")),

sortBy: gadgets.util.unescapeString(this.getPref("sortBy"))

with various params for the REST call.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events