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 edited

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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

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
AUG Leaders

Atlassian Community Events