Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

getting false remaining estimate in scriptrunner

Noam Twena June 19, 2023

I try to get remaining estimate field value of certain issues.

But it gives me false data (in milliseconds)

why?

 

----------------------------

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.component.ComponentAccessor


def issueInput = "foo-19852"

IssueManager issueManager = ComponentAccessor.getIssueManager()

def issue = issueManager.getIssueObject(issueInput)

def issueId = issue.getId()

def remainingEstimate = issue.getEstimate()
log.debug("remainingEstimate: ${remainingEstimate}")

----------------------

output:

remainingEstimate: 288000

---------------------

The actual remaining for this issue is: 2w

 

1 answer

1 accepted

0 votes
Answer accepted
Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2023

Hi @Noam Twena ,

What is the output if you convert the milliseconds ?

 

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.TimeTrackingUtils

def issueInput = "foo-19852"

IssueManager issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueInput)
def issueId = issue.getId()

def remainingEstimateMillis = issue.getEstimate()
def remainingEstimateFormatted = TimeTrackingUtils.formatDuration(remainingEstimateMillis)

log.debug("remainingEstimate: ${remainingEstimateFormatted}")

Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2023

Or ... is it possible that the result is in seconds ? It could be correct : 288000 seconds = 80 hours ... that's 10 working days of 8 hours

Like Noam Twena likes this
Noam Twena June 19, 2023
TimeUnit.MILLISECONDS.toDays(288000)
this would be 0
Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2023

I would try with TimeTrackingUtils.formatDuration(remainingEstimateMillis)

Just to be sure it's 0 also :-)

Noam Twena June 19, 2023

well unfortunately in the docs it says that the return value is in milliseconds:

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/Issue.html#getEstimate--

 

288000 from milliseconds to days in google give this number: 0.00333333333

so it doesn't really matter how I convert it

 

because the data I get doesn't make sense

Noam Twena June 19, 2023

Ok thanks @Frederik Vantroys , found by rest api call that this field is indeed calculated in seconds,

and indeed it makes sense that 288000 seconds are 2 weeks.

The return value in the docs is incorrect:

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/Issue.html#getEstimate--

Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 20, 2023

Glad it worked out.

Suggest an answer

Log in or Sign up to answer