forked from paulmunro/Rally
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCombined Productivity
345 lines (308 loc) · 11.9 KB
/
Combined Productivity
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Productivity Chart</title>
<meta name="Name" content="App: Productivity Chart"/>
<meta name="Version" content="1.0"/>
<meta name="Vendor" content="Tony Huang"/>
<link rel="stylesheet" type="text/css" href="/slm/css/rally/core.css" charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/slm/css/slm.css" charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/slm/css/sprites.css" charset="utf-8"/>
<script type="text/javascript" src="/slm/js-lib/dojo/1.3.1/dojo/dojo.js"></script>
<script type="text/javascript" src="/slm/js-lib/ejsc/2.1/EJSChart.js"></script>
<script type="text/javascript" src="/slm/mashup/1.20/js/batch-toolkit.js"></script>
<script type="text/javascript" src="/slm/mashup/1.20/js/utilities.js"></script>
<script type="text/javascript" src="/slm/js/slm.js"></script>
<script type="text/javascript">
dojo.addOnLoad(initPage);
dojo.require("dojo.date.stamp");
var MAX_ITERATIONS = 15;
var ESTIMATION_UNIT = "Points";
var KEY_PATTERN = /[^a-zA-Z0-9]+/g;
var batchToolkit;
var chart;
var iterationMap = new Array();
var PointsPerPersonSeries = [];
var PointsPerHourSeries = [];
if (!Number.toFixed) {
Number.prototype.toFixed = function(x) {
var temp = this;
temp = Math.round(temp * Math.pow(10, x)) / Math.pow(10, x);
return temp;
};
}
function formatDate(date) {
var day = date.getDate();
if (day < 10) {
day = "0" + day;
}
var month = date.getMonth() + 1;
if (month < 10) {
month = "0" + month;
}
var year = date.getFullYear();
return month + "/" + day + "/" + year;
}
function drawChart(resultsMap) {
if (typeof chart !== "undefined") {
chart.remove();
}
var sumPersonPoints = 0;
var sumHourPoints = 0;
var count = 0;
//Loop through the results and add up the points
for (var key in resultsMap) {
if (key != "errors" && key != "warnings") {
var stories = resultsMap[key];
var iterationKey = key.substring(key.indexOf("_")+1);
var estimate = 0;
// Loop through the storys for that iteration
for (var i = 0; i < stories.length; i++) {
var story = stories[i];
iterationMap[iterationKey].estimate += story.PlanEstimate;
}
}
}
for (var iterationKey in iterationMap) {
var perPerson = iterationMap[iterationKey].estimate / iterationMap[iterationKey].teamSize;
var perHour = iterationMap[iterationKey].capacity / iterationMap[iterationKey].estimate;
for (var i = 0; i < PointsPerPersonSeries.length; i++) {
if (PointsPerPersonSeries[i][0] == iterationMap[iterationKey].name) {
PointsPerPersonSeries[i][1] = perPerson;
sumPersonPoints += perPerson;
PointsPerHourSeries[i][1] = perHour;
sumHourPoints += perHour;
break;
}
}
count++;
}
var averageHours = (sumHourPoints / count).toFixed(3);
var averagePerson = (sumPersonPoints / count).toFixed(3);
var PERSON_SERIES_TITLE = "Points per Person";
var HOUR_SERIES_TITLE = "Hours per Point";
var PERSON_TREND_LINE_TITLE = "Points per Person Trend";
var HOUR_TREND_LINE_TITLE = "Hours per Point";
var HOUR_COLOR = "#CC0000";
var PERSON_COLOR = "#00BB00";
document.getElementById("average_div").innerHTML = "<strong>Average Productivity Rates for the last " +
count + " iterations:</strong>" +
"<div style=color:" + HOUR_COLOR + "> " + averageHours + " Hours/" + ESTIMATION_UNIT + " (less is better)</div>" +
"<div style=color:" + PERSON_COLOR + "> " + averagePerson + " " + ESTIMATION_UNIT + "/Person" + " (more is better)</div>";
chart = new EJSC.Chart("chart_div", {
show_legend: true,
legend_state: "minimized",
show_titlebar: false,
allow_zoom: false,
axis_bottom: {
caption: "Iterations",
stagger_ticks: true,
grid: {show: false},
size: 40
},
axis_left: {
min_extreme: 0.0,
caption: "Points"
}
});
var personSeries = new EJSC.BarSeries(
new EJSC.ArrayDataHandler(PointsPerPersonSeries),
{
title: PERSON_SERIES_TITLE,
color: PERSON_COLOR,
y_axis_formatter: new EJSC.NumberFormatter({
variable_decimals: 3
})
}
);
chart.addSeries(personSeries);
var hourSeries = new EJSC.BarSeries(
new EJSC.ArrayDataHandler(PointsPerHourSeries),
{
title: HOUR_SERIES_TITLE,
color: HOUR_COLOR,
y_axis_formatter: new EJSC.NumberFormatter({
variable_decimals: 3
})
}
);
chart.addSeries(hourSeries);
if (count > 1) {
var personTrendSeries = new EJSC.TrendSeries(
personSeries,
"linear",
{
title: PERSON_TREND_LINE_TITLE,
lineWidth: 1,
color: PERSON_COLOR,
opacity: 100,
y_axis_formatter: new EJSC.NumberFormatter({
variable_decimals: 3
})
}
);
chart.addSeries(personTrendSeries);
var hourTrendSeries = new EJSC.TrendSeries(
hourSeries,
"linear",
{
title: HOUR_TREND_LINE_TITLE,
lineWidth: 1,
color: HOUR_COLOR,
opacity: 100,
y_axis_formatter: new EJSC.NumberFormatter({
variable_decimals: 3
})
}
);
chart.addSeries(hourTrendSeries);
}
chart.onShowHint = function(point, series, chart, hint, hoverOrSelect) {
var hint = "";
switch(series.title) {
case HOUR_TREND_LINE_TITLE:
hint = "<strong>Hours per Point Trend:</strong> [y] " + "Hours/" + ESTIMATION_UNIT;
break;
case PERSON_TREND_LINE_TITLE:
hint = "<strong>Points per Person Trend:</strong> [y] " + ESTIMATION_UNIT + "/Person";
break;
case HOUR_SERIES_TITLE:
var key = point.x.replace(KEY_PATTERN, "_");
var startDate = RALLY.Mashup.Utilities.convertIsoDateOnly(iterationMap[key].startDate);
var endDate = RALLY.Mashup.Utilities.convertIsoDateOnly(iterationMap[key].endDate);
hint = "<strong>[x]</strong><br/><strong>Dates:</strong> " + formatDate(startDate) + " - " + formatDate(endDate) + "<br/>" +
"<strong>Accepted Points:</strong> " + iterationMap[key].estimate + " " + ESTIMATION_UNIT + "<br/>" +
"<strong>Planned Capacity:</strong> " + iterationMap[key].capacity + " Hours<br/>" +
"<strong>Hours per Point:</strong> [y] " + "Hours/" + ESTIMATION_UNIT;
break;
case PERSON_SERIES_TITLE:
var key = point.x.replace(KEY_PATTERN, "_");
var startDate = RALLY.Mashup.Utilities.convertIsoDateOnly(iterationMap[key].startDate);
var endDate = RALLY.Mashup.Utilities.convertIsoDateOnly(iterationMap[key].endDate);
hint = "<strong>[x]</strong><br/><strong>Dates:</strong> " + formatDate(startDate) + " - " + formatDate(endDate) + "<br/>" +
"<strong>Accepted Points:</strong> " + iterationMap[key].estimate + " " + ESTIMATION_UNIT + "<br/>" +
"<strong>Team Size:</strong> " + iterationMap[key].teamSize + " members<br/>" +
"<strong>Points Per Hour:</strong> [y] " + ESTIMATION_UNIT + "/Person";
break;
default:
throw "Unrecognized series: " + series.title;
}
return hint;
}
}
function loadCapacities(results) {
if (results.iterations.length == 0) {
document.getElementById("chart_div").innerHTML = "No Iterations for this project.";
return;
}
var queries = [];
var count = 0;
for (var i = 0; i < results.iterations.length && count < MAX_ITERATIONS; i++) {
var iteration = results.iterations[i];
var userCapacities = iteration.UserIterationCapacities;
var capacity = 0;
var memberCount = 0;
for (j = 0; j < userCapacities.length; j++) {
if (userCapacities[j].Capacity > 0) {
capacity += userCapacities[j].Capacity;
memberCount ++;
}
}
if (capacity > 0) {
var iterationKey = iteration.Name.replace(KEY_PATTERN, "_");
iterationMap[iterationKey] = {
name: iteration.Name,
startDate: iteration.StartDate,
endDate: iteration.EndDate,
estimate: 0,
capacity: capacity,
teamSize: memberCount
};
var defectQueryObject = {
key: "defect_" + iterationKey,
type: "defect",
fetch: "PlanEstimate",
query: "((Iteration.ObjectID = \"" + iteration.ObjectID + "\") AND (ScheduleState = \"Accepted\"))"
};
queries.unshift(defectQueryObject);
var queryObject = {
key: "story_" + iterationKey,
type: "HierarchicalRequirement",
fetch: "PlanEstimate",
query: "((Iteration.ObjectID = \"" + iteration.ObjectID + "\") AND (ScheduleState = \"Accepted\"))"
};
queries.unshift(queryObject);
PointsPerPersonSeries.unshift([iteration.Name, 0]);
PointsPerHourSeries.unshift([iteration.Name, 0]);
count++;
}
}
if (count > 0) {
batchToolkit.findAll(queries, drawChart);
} else {
document.getElementById("chart_div").innerHTML = "User Iteration Capacities have not been defined (set these values on the Team Status page).";
}
}
function runMainQuery() {
var today = dojo.date.stamp.toISOString(new Date(), {milliseconds: true, zulu: true});
var queryObject = {
key: "iterations",
type: "Iteration",
fetch: "Name,ObjectID,StartDate,EndDate,UserIterationCapacities,Capacity",
order: "EndDate desc",
query: "((Project.ObjectID = \"__PROJECT_OID__\") AND (EndDate <= " + today + "))"
};
batchToolkit.findAll(queryObject, loadCapacities);
}
function initPage() {
RALLY.Mashup.Utilities.showPrintButton();
batchToolkit = new RALLY.Mashup.BatchToolkit("__WORKSPACE_OID__", "__PROJECT_OID__",
"__PROJECT_SCOPING_UP__", "__PROJECT_SCOPING_DOWN__");
runMainQuery();
}
</script>
<style type="text/css">
body {
background: white;
}
.lbl {
text-align: left;
white-space: nowrap;
font-size: 13px;
}
td {
font-size: 11px;
}
</style>
</head>
<body>
<div class="titlebar" style="float: left;" id="title">Productivity Chart</div>
<table>
<tr>
<td style="text-align: left; width: 99%;">
<td style="text-align: right; width: 1%;">
<img id="do" onmouseover="RALLY.Mashup.Utilities.showcbButton();"
onmouseout="hidecbMenu('buttons',event);" style="vertical-align: middle;"
src="/slm/images/menu_actions.gif"/>
<div style="position:relative;top:5px" align="left">
<div id="buttons" class="do-menu" style="left:0px;"
onmouseover="document.body.style.cursor='pointer';"
onmouseout="document.body.style.cursor='default';hidecbMenu('buttons',event);">
<a id="print" onclick="RALLY.Mashup.Utilities.printPage()">Print...</a>
</div>
</div>
</td>
</tr>
</table>
<div style="clear: both;"></div>
<div style="padding: 5px; margin: 0px auto; background-color: #fff; width: 95%;">
<div id="average_div" style="margin-bottom: 20px;"></div>
<div id="chart_div" style="width:100%; height: 300px;">
<div>
<img alt="Progress" src="/slm/images/icon_spinner.gif"/>
<em>loading chart...</em>
</div>
</div>
</div>
</body>
</html>