Custom interval dimension for imported progress cycle measures

Hello! I need an interval dimension to help our teams analyze trends in cycle times (in workdays) of issues while assigned to an “in progress” status category. I have imported the progress cycle measures and would like to view the progress workday measure in 5-day intervals. It appears the most optimal solution would be to implement javascript to create the needed dimension. Can you provide an example of what that looks like? Thanks in advance!

This would be an extremely useful out of the box feature.

Hello @Drew_Grant !

Cycle day interval dimensions is a feature where we are collecting customer votes to decide when it might get into the development process.

And you are right currently possible workaround is a JavaScript calculated customfield dimension.

First, you would need to decide on using days, workdays, or work hours. In some cases workdays alone are not enough as business hours usually cover just one third of the day or close to that.

The JavaScript function for workhours can be found here - Assignment hrs work days eazybi - #2 by zane.baranovska.

Then, you need to create a JavaScript calculated customfield dimension calculating the actual time spent in the development cycle.

[jira.customfield_days_in_progress]
name = "In Progress workdays"
data_type = "integer"
dimension = true
javascript_code = '''
var transitto = Date.parse(issue.fields.created);
var statusList = ["Status 1","Status 2","Status 3","Status 4"];
var hours_in_statuses = 0;
var transitfrom = null;

issue.changelog.histories.forEach(function(history){
  history.items.forEach(function(historyItem){
    if (historyItem.field == "status") {
      transitfrom = Date.parse(history.created);
      var status = historyItem.fromString;
      if (statusList.indexOf(status) > -1) {
        hours_in_statuses += workinghours ( transitfrom , transitto ); 
      }
      transitto = transitfrom;
    }
  });
});
// divisor at end of next line denotes workhours in workday day  
  issue.fields.customfield_days_in_progress = hours_in_statuses/8;
'''
time_unit = "days"
time_interval = "duration"
intervals = "/5"
interval_unit = "days"

Regards,
Oskars / support@eazyBI.com

Thank you Oskar. The solution provided is configured for individual statuses. We need to look at the “status category” property instead as statuses can vary from project to project based on configuration. How might the Javascript be changed to reference the status category?

Hi @Drew_Grant ,

Since the status category is not provided within the issue changelog, it has to be requested via a separate REST API call.
You might read more about the Jira REST API endpoint here - https://developer.atlassian.com/server/jira/platform/rest/v10000/api-group-status/#api-api-2-status-get.

You might make that call at the beginning of the script and create reference list for status categories by status ID.

Using GetCachedDocument() function might prevent the 429 error and speed up the process.

The code might be as follows.

var statlist = new Array();
var result = getCachedDocument( "/rest/api/2/status", {ignoreErrors: "404"});
if (result && result.values ) {
 allStatuses = result
 for (i=0; i< allStatuses.length; i++){
   var currStat = allStatuses[i];
   if (currStat.statusCategory && currStat.statusCategory.name){
     statlist[currStat.id]= currStat.statusCategory.name;
   }}}

You also need to remove this line from the existing code.

var statusList = ["Status 1","Status 2","Status 3","Status 4"];

and replace the following line

      if (statusList.indexOf(status) > -1) {

with the following

      if (statlist[historyItem.from] == "In Progress") {

Regards,
Oskars / support@eazyBI.com