Show completed tasks per second

This commit is contained in:
simon987
2019-03-02 15:17:58 -05:00
parent 13290d3c55
commit e4936cd3c5
5 changed files with 34 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ export class ProjectDashboardComponent implements OnInit {
private timeline: Chart;
private statusPie: Chart;
private assigneesPie: Chart;
private avgTask: number;
private colors = {
@@ -336,6 +337,8 @@ export class ProjectDashboardComponent implements OnInit {
this.assignees = data.content.assignees;
this.setupAssigneesPie();
});
this.averageTaskPerSecond();
})
},
error => {
@@ -371,6 +374,27 @@ export class ProjectDashboardComponent implements OnInit {
this.setPaused(false)
}
private averageTaskPerSecond() {
const averageDelta = ([x, ...xs]) => {
if (x === undefined)
return NaN;
else
return xs.reduce(
([acc, last], x) => [acc + (x - last), x],
[0, x]
) [0] / xs.length
};
let interval = this.snapshots.length > 1 ? this.snapshots[0].time_stamp - this.snapshots[1].time_stamp : 0;
if (interval != 0) {
this.avgTask = averageDelta(this.snapshots.reverse().map(s => s.closed_task_count) as any) / interval;
} else {
return 0
}
}
private setPaused(paused: boolean) {
this.dialog.open(AreYouSureComponent, {
width: '250px',