Hi everyone,
Im running the script below to count the time an issue is "In Progress" status.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def inProgressName = "In Progress"
List<Long> rt = [0L]
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status")
changeItems.reverse().each {ChangeItemBean item ->
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())
}
def total = rt.sum() as Long
return (total / 1000) as long ?: 0L
What i need to do is the counter to restart from 0 when a new support employee presses again '' Start Working '' after pressing '' Undo Start Working '' .
Anyone have any idea how to do that? At the moment if it changes status it freezes counting and continues from where it was left when status changes again in "In Progress"
Thanx in advance,
George
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here