Show time in multiple statuses Edited

Hi,

I was hoping someone can help me with the following.
We've created a new Hierarchy as followed: Initiative - Epic - Story
What I would like to do is track how long it took for an Epic to get resolved. The tricky part is to measure Epics when they have an Initiative.

In short:

When an Epic has an Initiative the start date would be the transition of the Initiative to In progress and the end date would be when the Epic is resolved.

Else

When an Epic doesn’t have an Initiative the start date would simply be the transition of the Epic to In progress and the end date would be when the Epic is resolved

Would this be possible with Script Runner and can I use the following Script from Adaptavist as a basis?

 

import com.atlassian.core.util.DateUtils
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.history.ChangeItemBean

def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()

def inProgressName = "In Progress"

def rt = [0]
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
}
}

// NOTE: doesn't show anything if less than 60 seconds
DateUtils.getDurationString(Math.round(rt.sum() / 1000))

I know we can measure time with the Time in Status plugin but the plugin doesn't fit the need that I have.

All help is much appreciated!!

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 6 hours ago in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you