Name

global.BurnDownMetricUtil

Description

Utilities used by the burn down metrics

Script

var BurnDownMetricUtil = Class.create();

BurnDownMetricUtil.RELEASE_METRIC = "RM Release Total Story Count";
BurnDownMetricUtil.SPRINT_METRIC = "RM Sprint Total Story Count";
BurnDownMetricUtil.STORY_METRIC = "RM Story State Capture";

BurnDownMetricUtil.prototype = {
 initialize: function() {
 },
 
 insertMetric: function(metricInstance, startDate, field, fieldValue) {
    var gr = metricInstance.getNewRecord();
    gr.field = field;
    gr.field_value = fieldValue;
    gr.start = startDate;
    gr.end = startDate;
    gr.insert();
 },
 
 getCurrentMetric: function(definition, id) {
    var last = new GlideRecord("metric_instance");
    last.addQuery("id", id);
    last.addQuery("definition", definition);
    last.orderByDesc("start");
    last.query();
    
    if (last.next())
       return last;
    
    return null;
 },
 
 updateMetric: function(metricRecord, fieldValue) {
    metricRecord.field_value = fieldValue;
    metricRecord.end = new GlideDateTime();
    metricRecord.update();
 },
 
 // Check that the record being acted upon by the metric is not stale
 isStale: function(metric, source) {
    var gr = new GlideRecord("sys_audit");
    gr.addQuery("tablename", metric.definition.table);
    gr.addQuery("fieldname", metric.definition.field);
    gr.addQuery("documentkey", source.sys_id);
    gr.orderByDesc("record_checkpoint");
    gr.setLimit(1);
    gr.query();
    
    if (gr.next() && gr.record_checkpoint == source.sys_mod_count)
       return false;
    
    return true;
 },
 
 type: 'BurnDownMetricUtil'
};

Sys ID

0e82e82537231000a08a40ed9dbe5dcc

Offical Documentation

Official Docs: