mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-13 23:09:02 +00:00
Show completed tasks per second
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user