Jira: I need to display the sum of story points against a set of predfined lables.

Roderick Simons February 29, 2012

I already found and used the two dimensional statistics gadget. http://confluence.atlassian.com/display/JIRA/Adding+the+Two-Dimensional+Filter+Statistics+Gadget?focusedCommentId=278071565&#comment-278071565

I need some thing to display the sum of story points against a set of predefined labels. I can’t select story points in the two dimensional statistics gadget. Is there perhaps some other gadget that suits my needs?

Thanks!

1 answer

0 votes
mhenslee February 29, 2012

Here's some sample code to go off of if you want to write your own calculated custom field. I am summing the total story points over a parent issue and its linked issues (in this case, Test Cases.)

You could change this to look for certain labels using the getCustomFieldObjectByName method below and accessing the label field contents and check to see if those certain labels are met, etc. Then, you could even pass this custom field to the Two Dimensional Stats Gadget if needed.

Hope this helps!

public static Double getStoryPointsFromIssue(Issue iss)
	{
		//get the issue, and any links
		//if the issue has links
		//loop through each, get story point value, return total
		
		//get outward links for this feature
		List<IssueLink> outwardLinks;
		MutableIssue linkedIssue = null;
		
		Double total = 0.0;
		CustomField cf = customFieldManager.getCustomFieldObjectByName("Story Points");
		outwardLinks = defaultIssueLinkManager.getOutwardLinks(iss.getId());		
		
		//System.out.println("Outward Links:");
		//test plan has test cases.
		if(outwardLinks != null)
		{
			//loop through test cases
			for(IssueLink link : outwardLinks)
			{
				//get the test case for this iteration
				linkedIssue = link.getDestinationObject();
				//check for empty value or issue without Story Points
				if(linkedIssue.getCustomFieldValue(cf) != null)
				{
					//add, move to next issue
					total += Double.parseDouble(linkedIssue.getCustomFieldValue(cf).toString());
					
				}				
			}
		}
		return total;
	}

Suggest an answer

Log in or Sign up to answer