We need to create a Script Field that shows the user how many working hours (9AM to 6PM).
We have managed to generate the following script that is returning the TOTAL time that the issue is "In Progress" status.
import com.atlassian.core.util.DateUtils
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]
changeHistoryManager.getChangeItemsForField (issue, "status").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
total = (total/1000) as long ?: 0L
BigDecimal tot = total/3600
return tot
But we need to filter this to count the time only during the working hours (9AM to 6PM) and whenever this status is set to "In Progress" (even if it changes to other status beyond the working hours).
How can we do this?
Regards,
Victor Seger
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.