Hi Community!
I have created a custom field through scriptrunner, which shows the time an issue have been in the status "Under Review".
The field is created with the Duration template and is scripted as follows:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def inProgressName = "Under Review"
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
}
}
def total = rt.sum() as Long
return (total / 1000) as long ?: 0L
Currently the field displays the time in status with Weeks, Days, Hours and Minutes.
What i need, is for it to display the total time in hours only.
From looking around here in the community, I can see that i might have to import:
com.atlassian.jira.util.JiraDurationUtils.HoursDurationFormatter
But, I am unsure of how i change the actual output shown in the field, so it's only showing the total amount of hours.
Any help or hints are greatly appreciated.