The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to restart the calculating of time in a status of an issue

George Tsangaris
June 1, 2022

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 

 

 

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.