This repository was archived by the owner on Oct 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCycleTimeCalculator.js
More file actions
89 lines (74 loc) · 2.34 KB
/
Copy pathCycleTimeCalculator.js
File metadata and controls
89 lines (74 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(function() {
var Ext = window.Ext4 || window.Ext;
/**
* @private
* This class can be used to calculate cycle time
*/
Ext.define('CycleTimeCalculator', {
extend: 'Rally.data.lookback.calculator.TimeInStateCalculator',
runCalculation: function (snapshots) {
var data = [];
this.startDate = this._getStartDate(snapshots);
this.endDate = this._getEndDate(snapshots);
sortedSnapshots = _.sortBy(snapshots, function(s) {
return s.ObjectID;
});
groupedSnapshots = _.groupBy(sortedSnapshots, function(s) {
return s.ObjectID;
});
_.forEach(groupedSnapshots, function(oidSnapshots) {
var estimate = 0;
var cycleTime = 0;
var id = '';
var oid;
var xValue;
var lastDate;
_.forEach(oidSnapshots, function(snapshot) {
if( snapshot._ValidTo !== "9999-01-01T00:00:00.000Z" ){
cycleTime += this._calculateCycleTime(snapshot._ValidTo, snapshot._ValidFrom);
lastDate = new Date(snapshot._ValidTo);
}
estimate = snapshot.PlanEstimate;
id = 'US'+snapshot._UnformattedID;
oid = snapshot.ObjectID;
}, this);
xValue = this.singleStorySize ? undefined : estimate;
data.push({
x: xValue,
y: cycleTime,
id: id,
detailUrl: 'https://rally1.rallydev.com/#/2240613415/detail/userstory/'+oid,
lastDate: lastDate
});
}, this);
sortedData = _.sortBy(data, function(d) {
return d.lastDate;
});
trendData = this._fitData(sortedData);
return {
series: [
{
name: 'Stories',
data: sortedData
},
{
name: 'Trend Line',
type: 'line',
data: trendData
}
]
};
},
_fitData: function(source_data) {
var trend_source_data = [];
for(var i = source_data.length; i-->0;) {
trend_source_data.push([typeof source_data[i].x !== 'undefined' ? source_data[i].x : i , source_data[i].y]);
}
return fitData(trend_source_data).data;
},
_calculateCycleTime: function(to, from) {
MS_TO_DAYS = 1000 * 60 * 60 * 24; // MS/sec * sec/min * min/hr * hr/day
return (new Date(to) - new Date(from)) / MS_TO_DAYS;
}
});
})();