Skip to content

Commit 4c8e395

Browse files
authored
Merge pull request #2283 from Jamesbarford/feat/job-completion-count
Job completion progress in the timeline
2 parents f111973 + c0a6c87 commit 4c8e395

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

site/frontend/src/pages/status_new/collector.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import {h, ref, Ref} from "vue";
33
import {parseISO, differenceInHours} from "date-fns";
44
import {formatISODate, shortenTag} from "../../utils/formatting";
5-
import {CollectorConfig, BenchmarkJobStatus} from "./data";
5+
import {CollectorConfig, BenchmarkJobStatus, isJobComplete} from "./data";
66
77
const props = defineProps<{
88
collector: CollectorConfig;
@@ -56,9 +56,7 @@ function ActiveStatus({collector}: {collector: CollectorConfig}) {
5656
statusText = "Offline";
5757
statusClass = "offline";
5858
} else {
59-
const allJobsComplete = collector.jobs.every(
60-
(job) => job.status === "Failed" || job.status === "Success"
61-
);
59+
const allJobsComplete = collector.jobs.every(isJobComplete);
6260
if (allJobsComplete) {
6361
statusText = "Waiting";
6462
statusClass = "waiting";

site/frontend/src/pages/status_new/data.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ export type StatusResponse = {
4242
requests: BenchmarkRequest[];
4343
collectors: CollectorConfig[];
4444
};
45+
46+
export function isJobComplete(job: BenchmarkJob): boolean {
47+
return job.status === "Failed" || job.status === "Success";
48+
}

site/frontend/src/pages/status_new/page.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
BenchmarkRequestStatus,
1616
CollectorConfig,
1717
StatusResponse,
18+
isJobComplete,
1819
} from "./data";
1920
import Collector from "./collector.vue";
2021
@@ -122,6 +123,25 @@ function PullRequestLink({request}: {request: BenchmarkRequest}) {
122123
);
123124
}
124125
126+
function getJobCompletion(
127+
req: BenchmarkRequest,
128+
collectors: CollectorConfig[]
129+
) {
130+
const jobs = collectors
131+
.flatMap((c) => c.jobs)
132+
.filter((j) => j.requestTag === req.tag);
133+
if (jobs.length === 0) {
134+
return "";
135+
}
136+
const completed = jobs.reduce((acc, job) => {
137+
if (isJobComplete(job)) {
138+
acc += 1;
139+
}
140+
return acc;
141+
}, 0);
142+
return `${completed} / ${jobs.length}`;
143+
}
144+
125145
const {toggleExpanded: toggleExpandedErrors, isExpanded: hasExpandedErrors} =
126146
useExpandedStore();
127147
@@ -143,6 +163,7 @@ loadStatusData(loading);
143163
<th>Kind</th>
144164
<th>Tag</th>
145165
<th>Status</th>
166+
<th>Jobs Complete</th>
146167
<th>Completed At</th>
147168
<th>Duration</th>
148169
<th>Errors</th>
@@ -162,6 +183,9 @@ loadStatusData(loading);
162183
req.status === "Completed" && req.hasPendingJobs ? "*" : ""
163184
}}
164185
</td>
186+
<td>
187+
{{ getJobCompletion(req, data.collectors) }}
188+
</td>
165189
<td>
166190
{{ formatISODate(req.completedAt) }}
167191
<span v-if="req.endEstimated">(est.)</span>

0 commit comments

Comments
 (0)