PageRenderTime 57ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/resources/examples/TotalTimeInProgress.groovy

https://bitbucket.org/sorin/jira-plugin-intellij
Groovy | 27 lines | 20 code | 6 blank | 1 comment | 5 complexity | 012ea83b1ebe78de83bfc6c3d27a7840 MD5 | raw file
  1. package examples
  2. import com.atlassian.jira.ComponentManager
  3. import com.atlassian.jira.issue.history.ChangeItemBean
  4. import com.atlassian.jira.issue.Issue
  5. import com.atlassian.core.util.DateUtils
  6. def componentManager = ComponentManager.getInstance()
  7. def changeHistoryManager = componentManager.getChangeHistoryManager()
  8. def inProgressName = "In Progress"
  9. def rt = [0]
  10. changeHistoryManager.getChangeItemsForField (issue, "status").reverse().each {ChangeItemBean item ->
  11. item.toString == inProgressName
  12. def timeDiff = System.currentTimeMillis() - item.created.getTime()
  13. if (item.fromString == inProgressName) {
  14. rt << -timeDiff
  15. }
  16. if (item.toString == inProgressName){
  17. rt << timeDiff
  18. }
  19. }
  20. // doesn't show anything if less than 60 seconds
  21. DateUtils.getDurationString(Math.round(rt.sum() / 1000))