Skip to content

Commit c0a6c87

Browse files
committed
PR Feedback; change check for job progress & small refactor for job completion
1 parent 7c6ea6b commit c0a6c87

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
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: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {useExpandedStore} from "../../utils/expansion";
1313
import {
1414
BenchmarkRequest,
1515
BenchmarkRequestStatus,
16-
BenchmarkJob,
1716
CollectorConfig,
1817
StatusResponse,
18+
isJobComplete,
1919
} from "./data";
2020
import Collector from "./collector.vue";
2121
@@ -123,30 +123,23 @@ function PullRequestLink({request}: {request: BenchmarkRequest}) {
123123
);
124124
}
125125
126-
// This works off the assumption that all of the collectors are working on the
127-
// same request.
128126
function getJobCompletion(
129127
req: BenchmarkRequest,
130128
collectors: CollectorConfig[]
131129
) {
132-
const sampleJob = collectors?.[0]?.jobs?.[0];
133-
if (!sampleJob) return "";
134-
if (sampleJob.requestTag !== req.tag) return "";
135-
136-
const allJobs: BenchmarkJob[] = [];
137-
for (const collector of collectors) {
138-
allJobs.push(...collector.jobs);
130+
const jobs = collectors
131+
.flatMap((c) => c.jobs)
132+
.filter((j) => j.requestTag === req.tag);
133+
if (jobs.length === 0) {
134+
return "";
139135
}
140-
const completed = allJobs.reduce((acc, job) => {
141-
if (job.status === "Failed" || job.status === "Success") {
136+
const completed = jobs.reduce((acc, job) => {
137+
if (isJobComplete(job)) {
142138
acc += 1;
143139
}
144140
return acc;
145141
}, 0);
146-
if (allJobs.length) {
147-
return `${completed} / ${allJobs.length}`;
148-
}
149-
return "";
142+
return `${completed} / ${jobs.length}`;
150143
}
151144
152145
const {toggleExpanded: toggleExpandedErrors, isExpanded: hasExpandedErrors} =

0 commit comments

Comments
 (0)