Created
April 27, 2021 05:29
-
-
Save vikrantyadav11/83e112392d67f3d5e8a561dcd6a62b9b to your computer and use it in GitHub Desktop.
Calculate TIme in a Status
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
import com.atlassian.jira.component.ComponentAccessor | |
def changeHistoryManager = ComponentAccessor.changeHistoryManager | |
def currentStatusName = issue?.status?.name | |
def rt = [0L] | |
changeHistoryManager.getChangeItemsForField (issue, "status").reverse().each {item -> | |
def timeDiff = System.currentTimeMillis() - item.created.getTime() | |
if (item.fromString == currentStatusName) { | |
rt << -timeDiff | |
} | |
if (item.toString == currentStatusName){ | |
rt << timeDiff | |
} | |
} | |
def total = rt.sum() as Long | |
return (total / 1000) as long ?: 0L | |
//return (Math.round(rt.sum() / 3600000 / 24)) as Double | |
//return (Math.round(rt.sum() / 3600000)) as Double |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment