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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

792 views 2 19
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