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

@ -63,6 +63,7 @@ func (api *WebAPI) SubmitTask(r *Request) {
Message: "Too many requests", Message: "Too many requests",
RateLimitDelay: delay, RateLimitDelay: delay,
}, 429) }, 429)
reservation.Cancel()
return return
} }
@ -114,6 +115,7 @@ func (api *WebAPI) GetTaskFromProject(r *Request) {
Message: "Too many requests", Message: "Too many requests",
RateLimitDelay: delay, RateLimitDelay: delay,
}, 429) }, 429)
reservation.Cancel()
return return
} }

View File

@ -18,6 +18,10 @@
<p>{{"project.motd" | translate}}:</p> <p>{{"project.motd" | translate}}:</p>
<pre *ngIf="project">{{project.motd}}</pre> <pre *ngIf="project">{{project.motd}}</pre>
<p>{{"project.task_per_second" | translate}}:
<span class="text-mono" *ngIf="project">{{avgTask | number}}/s</span>
</p>
<div style="display: flex; align-items: center; justify-content: center"> <div style="display: flex; align-items: center; justify-content: center">
<div id="timeline-wrapper"> <div id="timeline-wrapper">
<canvas id="timeline"></canvas> <canvas id="timeline"></canvas>

View File

@ -26,6 +26,7 @@ export class ProjectDashboardComponent implements OnInit {
private timeline: Chart; private timeline: Chart;
private statusPie: Chart; private statusPie: Chart;
private assigneesPie: Chart; private assigneesPie: Chart;
private avgTask: number;
private colors = { private colors = {
@ -336,6 +337,8 @@ export class ProjectDashboardComponent implements OnInit {
this.assignees = data.content.assignees; this.assignees = data.content.assignees;
this.setupAssigneesPie(); this.setupAssigneesPie();
}); });
this.averageTaskPerSecond();
}) })
}, },
error => { error => {
@ -371,6 +374,27 @@ export class ProjectDashboardComponent implements OnInit {
this.setPaused(false) 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) { private setPaused(paused: boolean) {
this.dialog.open(AreYouSureComponent, { this.dialog.open(AreYouSureComponent, {
width: '250px', width: '250px',

View File

@ -73,7 +73,8 @@
"reset_response": "Reset failed tasks: ", "reset_response": "Reset failed tasks: ",
"assign_rate": "Task assign rate limit", "assign_rate": "Task assign rate limit",
"submit_rate": "Task submit rate limit", "submit_rate": "Task submit rate limit",
"rate": "per second" "rate": "per second",
"task_per_second": "Completed tasks per second"
}, },
"dashboard": { "dashboard": {
"title": "Dashboard for", "title": "Dashboard for",

View File

@ -73,7 +73,8 @@
"reset_response": "Réinitialisé les tâches en échec: ", "reset_response": "Réinitialisé les tâches en échec: ",
"assign_rate": "Taux d'assignation de tâches", "assign_rate": "Taux d'assignation de tâches",
"submit_rate": "Taux de soumission de tâches", "submit_rate": "Taux de soumission de tâches",
"rate": "par seconde" "rate": "par seconde",
"task_per_second": "Tâches par seconde"
}, },
"dashboard": { "dashboard": {
"title": "Tableau de bord pour ", "title": "Tableau de bord pour ",