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.
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))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.