Hello, I'm using the provided total time this issue has been In Progress groovy script.
I modified it so that it would tell me how long it was in it's initial "New" state. When I try and preview the answer, I get no answer whatsoever. The issue has been transitioned out of the status, and it was in that "New" status for about 5 days... any ideas?
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.history.ChangeItemBean import com.atlassian.jira.issue.Issue import com.atlassian.core.util.DateUtils def componentManager = ComponentManager.getInstance() def changeHistoryManager = componentManager.getChangeHistoryManager() def inProgressName = "New" def rt = [0] def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status") changeItems.reverse().each {ChangeItemBean item -> item.toString == inProgressName def timeDiff = System.currentTimeMillis() - item.created.getTime() if (item.fromString == inProgressName) { rt << -timeDiff } if (item.toString == inProgressName){ rt << timeDiff } } if (! changeItems) { rt << (System.currentTimeMillis() - issue.getCreated().getTime()) } // doesn't show anything if less than 60 seconds DateUtils.getDurationString(Math.round(rt.sum() / 1000))
Modified the script as such:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.history.ChangeItemBean import com.atlassian.jira.issue.Issue import com.atlassian.core.util.DateUtils def componentManager = ComponentManager.getInstance() def changeHistoryManager = componentManager.getChangeHistoryManager() def inProgressName = "New" def rt = [0] def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status") changeItems.reverse().each {ChangeItemBean item -> item.toString == inProgressName def timeDiff = System.currentTimeMillis() - item.created.getTime() if (item.fromString == inProgressName) { rt << -timeDiff } if (item.toString == inProgressName){ rt << timeDiff } } if (! changeItems) { rt << (System.currentTimeMillis() - issue.getCreated().getTime()) } rt << (System.currentTimeMillis() - issue.getCreated().getTime()) double hours = rt.sum()/1000/60/60
Adding in the
rt << (System.currentTimeMillis() - issue.getCreated().getTime())
at the end made the "New" state finally get calculated the right way. Also, to make the field queryable (although less pretty) I kept it in number form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.