Hi!
How i can show up days count of last transition.
I dont need calculate total, this value should be refreshable and setted per new transition.
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))
Can some one help me?
OK:
import com.atlassian.jira.component.ComponentAccessor def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() def items = changeHistoryManager.getChangeItemsForField (issue, "status").reverse() if (items) { return ((new Date().time - items.first().created.time) / 1000) as Long } else { return ((new Date().time - issue.getCreated().time) / 1000) as Long }
Searcher: Duration
Custom template:
#if ($value) $jiraDurationUtils.getFormattedDuration($value) #end
You are the best, thanks! This working for me =)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @JamieA
I want to calculate the time from create to solve the issue, and how can I get this? The value I hope to get is: the time point when the issue is closed minus the time point when the issue is created, and the corresponding value. I wonder if you can understand my demand
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @JamieA , great solution!
I found a small way to enhance this by changing to Custom template:
#if ($value) F553; $DateUtils.getDurationString($value) #end
Which adds a leading clock face symbol and displays duration in the shortest format..
🕓 1w 18h 10m
Hope this is useful to others.
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.
getDurationString should return you a properly formatted duration...
Best thing is to return a Long then use the template as I originally recommended. I don't think the search will work though. Try all this with no searcher.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll tried this all with searcher "None" and with sting/long combinations:
$jiraDurationUtils.getDurationString($value)
$jiraDurationUtils.getFormattedDuration($value)
$jiraDurationUtils.getDaysDurationFormatter($value)
$jiraDurationUtils.getHoursDurationFormatter($value)
$jiraDurationUtils.getPrettyDurationFormatter($value)
$jiraDurationUtils.getShortFormattedDuration($value)
It doesnt worked in JIRA 6.4.5 and Script Runner v 3.1.4
Nevertheless thank you @Jamie Echlin [Adaptavist].
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Change the searcher for the field to Duration, as I said in my answer. If you don't see Duration you might be using an older version, if so which one?
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.
Set the searcher for the field to None then, but it's best if you can upgrade so you can using the duration indexer. You didn't answer the question about whether it was there by the way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jamie Echlin [Adaptavist]
I did what you recommended, so i can see now is that it is:$jiraDurationUtils.getFormattedDuration($value)
Untitled111.jpg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jamie Echlin [Adaptavist] Hi!
Please, clarify.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie, yes.
Could you add more details here, sorry but i dont know how realise it via groovy code, can you advise please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You just want the time in the current status? Then you just need to subtract the first change item returned from the current date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Yes, you right.
This code show me total days. But i'm needed to show up days according each transition to this status (not total).
For example (how this should work):
I changed my status from Open to In-Progress yesterday, and now i see 1 day,
I changed it status to on-hold, then i am again changed it to in-progress and now i see 1 min,
do you understand?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you elaborate on "How i can show up days count of last transition". Why did you post that code, is that what you have tried?
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.