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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,798 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot