Hi All,
I have a problem: I need to get the time spent in In progress + Open statuses for each issue.
I made a script (scripted field) but it fails. Can you please help?
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 onHoldName = "Open" def rt = [0] // // Loops through every status change // changeHistoryManager.getChangeItemsForField (issue, "status").reverse().each {ChangeItemBean statusChange -> // Get the time passed since status change def timeDiff = System.currentTimeMillis() - statusChange.created.getTime() // If the status change left our status, we want to subtract the time passed since then if (statusChange.fromString == inProgressName) { rt << -timeDiff } if (statusChange.fromString == onHoldName) { rt << -timeDiff } // If the status change goes to our status, we want to add the time passed since then if (statusChange.toString == inProgressName) { rt << timeDiff } if (statusChange.toString == onHoldName) { rt << timeDiff } } // // Now compute the sum of all array elements. // Devide by 1000 to not show anything less than 60 seconds
Try the below code . I have not tested it but modified the existing code which i found in the script runner docs. Hope it helps
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 } } def inOpen = "Open" def rt1 = [0] changeHistoryManager.getChangeItemsForField (issue, "status").reverse().each {ChangeItemBean item -> def timeDiff1 = System.currentTimeMillis() - item.created.getTime() if (item.fromString == inOpen) { rt1 << -timeDiff1 } if (item.toString == inOpen){ rt1 << timeDiff1 } } DateUtils.getDurationString(Math.round(rt1.sum() / 1000)+Math.round(rt.sum() / 1000))
Hi Mizan,
I tested but it failed:
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: Open for class: Script21 A stacktrace has been logged.
Thanks for help!
Rumi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rumi ,
I have edited the above code you can try it now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I tested your code and I get:
javax.script.ScriptException: java.lang.NumberFormatException: For input string: "9m" A stacktrace has been logged.
It seems to me that the code sums the 'In progress' time spent but exclude the Open status. And the result ("9m") is in the warning message not in the proper custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have edited the above script , i am not sure i think this wont give proper results ..
How about adding 2 scripted feilds (hide these 2 using behaviours plugin) one for Inprogress time and other for Open time and a 3rd field which will display the sum of these custom fields .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did this ever work out?
I'm having the same problem with Open status
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is a Time in Status Plugin on marketplace. You can get reports depending on user, project and advanced mode. You can export the reports to excel also.
Tansu Akdeniz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Such a simple thing and Jira cannot do it? Really? After all these years adding features? Incredible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
please, try on https://marketplace.atlassian.com/plugins/ru.andreymarkelov.atlas.plugins.datacollector
-- Andrey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.