Hi, after updating to version 6.5.2 it stopped working Cycle date and Cycle days.
[jira.customfield_cycle_date]
name = "Cycle date"
data_type = "datetime"
measure = true
javascript_code = '''
var cycleStatuses = ["In Progress"];
cycleDate = null;
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
var histories = issue.changelog.histories;
for (var i = 0; i < histories.length; i++) {
var history = histories[i];
if (history.items && history.items.length > 0) {
for (var n = 0; n < history.items.length; n++) {
var item = history.items[n];
if (item.field == 'status') {
movedToStatus = item.toString;
if(cycleStatuses.indexOf(movedToStatus) > -1) {
cycleDate = history.created;
break ; //disable this line if the last date is needed. Break closes the iteration through status history
}
} } } }
issue.fields.customfield_cycle_date = cycleDate;
}
'''
interval 00-00, but tasks clearly fall into it with a large interval from status analysis to closed.
[jira.customfield_cycledays]
name = "Cycle days"
data_type = "decimal"
dimension = true
measure = true
javascript_code = '''
if (issue.fields.resolutiondate) { // calculate for resolved issues only
var transitto = Date.parse(issue.fields.created);
// specify a list of statuses in cycle :
var statuslist = ["In Progress","In Review"];
var timeInStatus = null;
var transitfrom = null;
// iterate through chengelog entries to get the status changes
issue.changelog.histories.forEach(function(history){
history.items.forEach(function(historyItem){
if (historyItem.field == "status") {
transitfrom = Date.parse(history.created);
status = historyItem.fromString;
// validate the status by status name
if (statuslist.indexOf(status) > -1) {
// add time when issue moves out of the status
timeInStatus += (transitfrom - transitto) / 1000 / 60 / 60 / 24 ;
}
transitto = transitfrom;
}
});
});
if (timeInStatus) {
issue.fields.customfield_cycledays = timeInStatus;
}
}
'''
time_unit = "days"
time_interval = "duration"
intervals = "/10"
interval_unit = "days"