Skip to content

Commit a5b4bae

Browse files
committed
Throughput fix
1 parent fa9c2a7 commit a5b4bae

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/public/javascript/services/report.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const ReportService = (($, _, moment, App, Util, ColumnService) => ({
4040
.map((summary) => {
4141
_.each(summary.board_moves, (move) => {
4242
const date = moment.utc(move.when);
43+
move.date = date;
4344
move.day = date.date();
4445
move.month = date.month() + 1;
4546
move.year = date.year();
@@ -325,47 +326,47 @@ const ReportService = (($, _, moment, App, Util, ColumnService) => ({
325326
/**
326327
* @param data
327328
* @param project
328-
* @param from
329-
* @param to
330329
* @return {{labels, datasets}}
331330
*/
332-
getThroughputData: async (data, project, from, to) => {
331+
getThroughputData: async (data, project) => {
333332
const columns = await ColumnService.listForProject(project.id);
334333
const summaries = ReportService._normalizeData(data, project, columns);
335334

336335
const labels = _(summaries)
337336
.map('board_moves')
338337
.flatten()
339338
.sortBy('millis')
340-
.map('weekOfYear')
341-
.uniq()
339+
.map(move => ({
340+
firstWeekDay: move.date.isoWeekday(1).format('DD/MM/YYYY'),
341+
weekOfYear: move.weekOfYear,
342+
}))
343+
.uniqBy('weekOfYear')
342344
.value();
343345

344-
const datasets = _(summaries)
346+
const datasets = [];
347+
348+
const totals = _(summaries)
345349
.map('board_moves')
346350
.flatten()
347-
.filter((move) => {
348-
return move.to_column.order === _(columns).filter('visible').filter(move => move.order > 0).maxBy('order').order;
349-
})
351+
.sortBy('millis')
350352
.groupBy('weekOfYear')
351-
.map((week, key) => {
352-
const data = labels.map((w) => {
353-
const isSameWeek = (Number(w) === Number(key));
354-
return isSameWeek ? week.length: 0;
355-
});
356-
357-
return {
358-
data,
359-
label: key,
360-
fill: false,
361-
borderColor: randomColor(),
362-
pointRadius: 10,
363-
};
353+
.map((week) => {
354+
return _.filter(week, (move) => {
355+
return move.to_column.order === _(columns).filter('visible').filter(move => move.order > 0).maxBy('order').order;
356+
}).length;
364357
})
365358
.value();
366359

360+
datasets.push({
361+
data: totals,
362+
label: 'Closed Issues',
363+
fill: false,
364+
borderColor: 'blue',
365+
pointRadius: 10,
366+
});
367+
367368
return {
368-
labels,
369+
labels: _.map(labels, 'firstWeekDay'),
369370
datasets,
370371
};
371372
},

0 commit comments

Comments
 (0)