How can I get cycle time for epics via the API

Todd Main March 7, 2016

How can I get the data from the API for how long an issue (epic) spent in each status, or at least in an "In Progress" status, so that I can calculate cycle time?  Yes, I've seen the control chart, but I can't use them for my purpose.

 

1 answer

0 votes
Vasiliy Zverev
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.
March 10, 2016

I use this code for this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.changehistory.ChangeHistory
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
import com.atlassian.jira.issue.history.ChangeItemBean

/**
 * Return time between two statuses
 */

//Issue issue = null;
long endStatusTime = 0;

String endStatusName = "Закрыт"

ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager();
for(ChangeHistory changeHistory: changeHistoryManager.getChangeHistories(issue))
    for(ChangeItemBean changeItemBean: changeHistory.getChangeItemBeans()) {
        if (changeItemBean.getField().equals("status")){

             if( changeItemBean.getToString().equals(endStatusName) ){
                endStatusTime = changeItemBean.getCreated().getTime()
            }
        }
    }

return  String.format("%.2f", (endStatusTime - issue.getCreated().getTime())/(1000*60*60*24))
Todd Main March 10, 2016

Thanks - I'll give it a try!

Suggest an answer

Log in or Sign up to answer