Retrieve“Time Spent” value under Work Log in JIRA

Balu G September 24, 2019

I would like to write a JQL to retrieve the time spent on a specific sub-task. Below is my query. Sadly, what is being returned is the aggregate value of time spent and not the individual value as shown in the picture below.

This is my query below. Unfortunately, the result is showing an aggregated value. For e.g., it is displaying 6 hours instead of 3 hours (see "Results" picture below).

JIRA.jpg

 

 

Results

Results.png

2 answers

0 votes
Balu G September 25, 2019

Hi Fran, Thanks for responding. Can you elaborate on how to use the REST API

 

https://{your_url}/rest/api/latest/issue/{your_issuekey}/worklog 

 

What is "your_url" here and how do I use it? Is ScriptRunner free to use? I am afraid that my company won't pay to buy add-ins.

fran garcia gomera
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.
September 25, 2019

your url is your jira url (something like 'xxxx.jira.com') you only have to make a GET request to that url and you'll receive a JSON with worklog data, the structure is like this

{
    "startAt": 0,
    "maxResults": 1,
    "total": 1,
    "worklogs": [
        {
            "self": "http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000",
            "author": {
                "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
                "name": "fred",
                "displayName": "Fred F. User",
                "active": false
            },
            "updateAuthor": {
                "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
                "name": "fred",
                "displayName": "Fred F. User",
                "active": false
            },
            "comment": "I did some work here.",
            "visibility": {
                "type": "group",
                "value": "jira-developers"
            },
            "started": "2013-08-23T16:57:35.985+0200",
            "timeSpent": "3h 20m",
            "timeSpentSeconds": 12000,
            "id": "100028"
        }
    ]
}


You have more info here: https://docs.atlassian.com/DAC/rest/jira/6.1.html#d2e1552

Hope this helps you

0 votes
fran garcia gomera
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.
September 25, 2019

JQL retrieves issues, and the field Time Spent for an issue is the total time spent.

On the DB you there is a worklog table, and via API you can also access every log

https://{your_url}/rest/api/latest/issue/{your_issuekey}/worklog 

fran garcia gomera
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.
September 25, 2019

If you have scriptrunner instaled, you also can access the issues that were  logged by a certain user or in a certain date. (https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html#_worklogs)

issueFunction in workLogged(on "2015/07/28" by admin)

 But you get the issue, with its Time Spent showing the total

Suggest an answer

Log in or Sign up to answer