Last active
August 29, 2015 13:59
-
-
Save jechlin/10928320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package examples.old | |
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 = "Open" | |
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)) ?: "0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment