Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions site/frontend/src/pages/status_new/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {useExpandedStore} from "../../utils/expansion";
import {
BenchmarkRequest,
BenchmarkRequestStatus,
BenchmarkJob,
CollectorConfig,
StatusResponse,
} from "./data";
Expand Down Expand Up @@ -122,6 +123,32 @@ function PullRequestLink({request}: {request: BenchmarkRequest}) {
);
}

// This works off the assumption that all of the collectors are working on the
// same request.
function getJobCompletion(
req: BenchmarkRequest,
collectors: CollectorConfig[]
) {
const sampleJob = collectors?.[0]?.jobs?.[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need such assumption, it might break if we had backfilled jobs, and the first collector can be offline/inactive/not relevant. What about something like this:

const jobs = collectors.flatMap(c => c.jobs).filter(j => j.requestTag === req.tag);
if (jobs.length === 0) {
    return "";
}
const completed = jobs.reduce((acc, job) => {
    if (job.status === "Failed" || job.status === "Success") {
      acc += 1;
    }
    return acc;
  }, 0);
return `${completed} / ${jobs.length}`;

Also, we already have the same check for "Failed" / "Success" when determining the collector status. It would be nice to separate that logic into a shared function, something like function isJobCompleted(job: BenchmarkJob): boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9f40a84 👍

if (!sampleJob) return "";
if (sampleJob.requestTag !== req.tag) return "";

const allJobs: BenchmarkJob[] = [];
for (const collector of collectors) {
allJobs.push(...collector.jobs);
}
const completed = allJobs.reduce((acc, job) => {
if (job.status === "Failed" || job.status === "Success") {
acc += 1;
}
return acc;
}, 0);
if (allJobs.length) {
return `${completed} / ${allJobs.length}`;
}
return "";
}

const {toggleExpanded: toggleExpandedErrors, isExpanded: hasExpandedErrors} =
useExpandedStore();

Expand All @@ -143,6 +170,7 @@ loadStatusData(loading);
<th>Kind</th>
<th>Tag</th>
<th>Status</th>
<th>Jobs Complete</th>
<th>Completed At</th>
<th>Duration</th>
<th>Errors</th>
Expand All @@ -162,6 +190,9 @@ loadStatusData(loading);
req.status === "Completed" && req.hasPendingJobs ? "*" : ""
}}
</td>
<td>
{{ getJobCompletion(req, data.collectors) }}
</td>
<td>
{{ formatISODate(req.completedAt) }}
<span v-if="req.endEstimated">(est.)</span>
Expand Down
Loading