Name

global.SprintBurndown

Description

This utility include used for sprint burndown json.

Script

var SprintBurndown = Class.create();

SprintBurndown.prototype = {
  
  initialize: function ( burndownRequest ) {
      this.sysId = burndownRequest['sysId'];
      this.burndownMetric = new BurndownMetric(burndownRequest);
      this.gsLog = new GSLog(this.burndownMetric.SCRUM_PP_BURNDOWN_LOG, this.type);
      this.gsLog.setLevel("debug");
      this.gsLog.logDebug('SprintBurndown sysId: ' + this.sysId);
  },
  
  getBurndownMetric: function() {
      return this.burndownMetric;
  },
  
  canProcessBurndown: function() {
      if (this.burndownMetric.hasMetricData() && this.burndownMetric.hasValidDates()) {
          return true;
      }
      return false;
  },
  
  generate: function() {
      var jsonStringfy = '';
      var actualData = this.actual();
      var idealData = this.burndownMetric.getIdeal();
      var dailyData = this.burndownMetric.getDailyPoints();
      var sprintData = this.burndownMetric.getSprintDetail();
      var jsonOutput = {actual: actualData,
      ideal: idealData,
      total: dailyData,
      title: this.burndownMetric.getTitle()
  };
  return jsonOutput;
},

actual: function() {
  var data = [];
  var dailyTotalsMap = this.burndownMetric.getDailyTotalsMap();
  var storyMetrics = this.burndownMetric.getStoryMetrics();
  var startDate =  this.burndownMetric.getStartDate().getLocalDate();
  var endDate = this.burndownMetric.getEndDate().getLocalDate();
  var today = new GlideDate().getLocalDate();
  var points = 0;
  while (startDate.compareTo(endDate) <= 0 && startDate.compareTo(today) <= 0) {
      points += storyMetrics[startDate] ? storyMetrics[startDate] : 0;
      
      data.push({
          // key: String(new GlideDateTime(startDate).getDate()),
          key: String(startDate),
          value: Math.max(dailyTotalsMap[startDate].dailyPoints + points, 0)
      });
      /*this.gsLog.logDebug('actual{key: '+ String(new GlideDateTime(startDate).getDate()) + ' ,value: ' + Math.max(dailyTotalsMap[startDate].dailyPoints + points, 0) + '}');*/
      startDate.addDays(1);
  }
  return data;
},

type:  'SprintBurndown'
};

Sys ID

c84824629f022100598a5bb0657fcf37

Offical Documentation

Official Docs: