I need to search all stories in a PROJECT, summing up a total of the story points, if any, found!

bauerprocessconsulting December 23, 2017

I need to search all stories in a PROJECT, summing up a total of the story points, if any, found!

I know how to sum up story points of stories in an epic, and I know how to sum up story points from linked issues - but i cant get my mind around a solution for summing up the story points for a project - and as it happens, this is exactly what i need to do. Someone please help - this i driving me crazy!

3 answers

1 vote
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 27, 2017

Hello @bauerprocessconsulting,

You could be using the following as a base project:

# Python

import requests, json

baseRestApiUrl = "http://localhost:8080/rest/api/2"
endpointFields = "/field"
endpointSearch = "/search"

jiraUsername = "admin"
jiraPassword = "mysecretpassword"

headers = {'Content-Type': 'application/json'}

def getCustomField(fieldName):
r = requests.get(
baseRestApiUrl + endpointFields,
auth=(jiraUsername, jiraPassword),
headers=(headers),
verify=False)

for field in r.json():
if field['name'] == fieldName:
return field['id']

def sumStoriesWithStoryPoints(projectKey):
r = requests.get(
baseRestApiUrl + endpointSearch + '?jql=project%3D' + projectKey,
auth=(jiraUsername, jiraPassword),
headers=(headers),
verify=False)

total = 0.0
for issue in r.json()['issues']:
total += issue['fields'][getCustomField('Story Points')]

print total

sumStoriesWithStoryPoints('PROJ')

Kind regards,

Rafael

bauerprocessconsulting December 27, 2017

Thanks Rafael

 

The approach you suggest is much more elegant (and fast) than the solution i have come up with (Groovy embedded JQL).

 

I am going to Work with your code moving forward.

 

Let me say that it is really great that you took the time to really help, not just throw a remark or a pointer.

 

I hope that i can "repay you" by also submitting some of my ideas if that can, one day, help someone else.

 

Thanks!

rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 28, 2017

I am glad I could help you somehow.

Have a Happy New Year!!

0 votes
Alexey Matveev
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.
December 24, 2017

You would need to create a scripted field with a code which would go through all necessary links from the current issue and sum up all the story points. The script would depend on the links you use.

0 votes
bauerprocessconsulting December 23, 2017

Further info: i know how to sum up the story points of stories in a project using JQL - but i need to do it using scriptrunner/groovy in a scripted field....something like a "for each"-like traversing thingie....

Suggest an answer

Log in or Sign up to answer