Under Construction...
JIRA API is simple and straight forward. I only faced an issue while trying to pull my teams effort on each ticket.
The issue was, JIRA API returns max 100 rows on root level and also on sub level.
Meaning, if there is a ticket where multiple team members involved and effort logged (worklog) for more than 100 times, you wont get them all in single call. So you have to make multiple calls and there was no web search took me not even near to what i was looking for.
A Typical JIRA REST API CALL GOES LIKE THIS
rest/api/3/search?jql=(project in ('MyProject') AND worklogDate>="2020-8-01" AND worklogDate<="2020-8-31" AND issuetype not in ("something","thatthing","Otherthing"))&Orderby =Worklogdate desc&startAt=0&maxResults=100&fieldsByKeys=true&fields=workratio,project,created,issue,key,summary,created,worklog,timespent,assignee,displayname,aggregatetimespent,timeestimate,worklog,issuetype,worklogDate
From the result, the worklogs is an array but contains max 20/50 records. It Never returns the whole list.
"worklog": { "startAt": 0, "maxResults": 20, "total": 200, "worklogs": []}The below method will take any JBL and fire it against your JIRA server and pull all matched tickets and the whole efforts spent on each ticket. We had the result applied on pivot table heat map rendering and the result was stunning.
<cffunction name="ExecuteJQL" output="true" hint="executes any given jql."> <cfargument name="jqlQuery" required="false" default=""> <cfargument name="fields" required="false" default = ""> <cfargument name="startat" required="false" default = "0"> <cfset maxResults = 100 /> <!--- as of now the max allowed in JIRA is 100 ---> <cfset issuesFound = 100 /> <cfset totalFound = 101 /> <cfset jqlQuery = len(jqlQuery) ? jqlQuery : "(worklogDate>=startOfMonth() AND worklogDate<=endOfMonth() AND Project='MyProject' AND issuetype not in ('Prod Incident','Bug','Inquiry'))" /> <cfset jqlQuery = jqlQuery & (len(trim(fields)) ? "&fieldsByKeys=true&fields=#fields#" : "") /> <cfloop condition = "issuesFound gte maxResults and issuesFound lt totalFound"> <cfset jqlQueryPaging = "?jql=#jqlQuery#&startAt=#startat#&maxResults=#maxResults#" /> <cfset jqlResult = instance.client.get("/rest/api/3/search#jqlQueryPaging#") /> <cfif IsDefined("jqlResult.data.issues") && arraylen(jqlResult.data.issues)> <cfset issuesFound = arraylen(jqlResult.data.issues) /> <cfset totalFound = jqlResult.data.total /> <cfset startat+=maxResults /> <cfloop array="#jqlResult.data.issues#" index="local.isu"> <cfset itemsFound_w = local.isu.fields.worklog.maxResults /> <cfset totalFound_w = local.isu.fields.worklog.total /> <cfif itemsFound_w lt totalFound_w> <!--- reset worklog -- so it will fetch freshly---> <cfset local.isu.fields.worklog.worklogs = [] /> <cfset itemsFound_w = 0 /> <cfloop condition = "itemsFound_w lt totalFound_w"> <cfset jqlResult_w = instance.client.get("/rest/api/3/issue/#local.isu.id#/worklog") /> <cfif !isdefined('jqlResult_w.data.worklogs')><cfdump var =#jqlResult_w# abort /></cfif> <cfset arrayAppend(local.isu.fields.worklog.worklogs, jqlResult_w.data.worklogs, true) /> <cfset itemsFound_w += arraylen(jqlResult_w.data.worklogs) /> </cfloop> </cfif> </cfloop> <cfif isdefined('instance.JiraIssues.data.issues')> <cfset arrayAppend(instance.JiraIssues.data.issues, jqlResult.data.issues, true) /> <!---<cfloop array="#jqlResult.data.issues#" index="local.i"> <cfset arrayAppend(instance.JiraIssues.data.issues, local.i)> </cfloop>---> <cfelse> <cfset StructAppend(instance.JiraIssues, jqlResult, true) /> </cfif> <cfelse> <cfbreak /> </cfif> </cfloop> <!---<cfif startat gte totalFound and !StructIsEmpty(instance.JiraIssues)> <cfdump var = #arraylen(instance.JiraIssues.data.issues)# abort/> </cfif>---> <cfset instance.JiraIssues["jqlUsed"] = IsDefined("jqlQueryPaging") ? jqlQueryPaging : jqlQuery /> <cfreturn instance.JiraIssues /> </cffunction>JsonClient is something like one you will find in Ben Nadel (All credit goes to him)