How would i write an API query to get the total time logged in JIRA on issues this week for each user?
/rest/api/2/search with some jql magic and then reduce the resulting array!
worklogDate > 2017-1-07to get issues for past week
timespent > 0to get only issues which have time logged
fields=worklogparameter to get the logging info
So you get the final query like
You need two more steps to get total time logged:
- map the results to get an array of all worklogs
- reduce the array to get the desired total time
const worklogs = results.map(result => result.field.worklog.worklogs).reduce((a,b) => a.concat(b) (1)
const totalTimeLogged = worklogs.reduce((value, worklog) => value += worklog.timeSpentSeconds, 0) (2)
is there a new way to do it now with the api 3?
could you please give some insight on how to use this API? I am very amateur in technical.
My requirement is, I want to generate report to track the time logged or efforts spent by each user in a sprint for a particular JIRA item. I am not able to use the “Time Spent” field as it only considers the consolidated efforts spent from the start of the JIRA task. The JIRA task can be spill over to the next sprint. But I want to understand the efforts logged by each user in a particular sprint or in a specific time frame. Hope I am clear in explaining.