How long Issue was flagged to Paused (Cumulative)

Hi,

We can adjust the Javascript calculated custom field to allow the cumulative calculation of this measure over time. Currently, the code accumulates all the flagged periods in a single total, but it is possible to record each period separately in the measure.

The settings of this measure are the following:

#Days Flagged Cumulative
[jira.customfield_days_flagged_c]
name = "Days Flagged Cumulative"
multiple_dates=true
data_type="decimal"
measure = true
javascript_code='''
var date_from = Date.parse(issue.fields.created);
var days_flagged = 0.0;
var result = new Array();
issue.changelog.histories.forEach(function(history){
    history.items.forEach(function(historyItem){
      if (historyItem.field == "Flagged") {
        to = historyItem.toString;
        from = historyItem.fromString;
        if(to.equals("Impediment")) {
          date_from = Date.parse(history.created);
        }
        if (from && from.equals("Impediment")) {
          date_to = Date.parse(history.created);
          days_flagged = (date_to - date_from) / 1000/ 60 /60 / 24 ;
          result.push(history.created.substr(0,10)+","+days_flagged);
        }
      }
   });
});
if (days_flagged>0) 
  issue.fields.customfield_days_flagged_c=result.join("\n");
'''

This measure gives the same value in total but can be distributed by dates if an issue was flagged several times:

Kindly,
Janis, eazyBI support