Skip to content

Commit 8be452a

Browse files
authored
Merge pull request #2339 from Kobzol/collector-compress
Modify UI of the status page
2 parents d16d3ec + 25b3936 commit 8be452a

File tree

2 files changed

+75
-28
lines changed

2 files changed

+75
-28
lines changed

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

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<script setup lang="tsx">
22
import {h, ref, Ref} from "vue";
3-
import {parseISO, differenceInHours} from "date-fns";
4-
import {formatISODate} from "../../utils/formatting";
3+
import {
4+
parseISO,
5+
differenceInHours,
6+
differenceInSeconds,
7+
format,
8+
} from "date-fns";
9+
import {
10+
formatISODate,
11+
formatSecondsAsDuration,
12+
parseDateIsoStringOrNull,
13+
} from "../../utils/formatting";
514
import {
615
CollectorConfig,
716
BenchmarkJobStatus,
817
isJobComplete,
918
BenchmarkJob,
19+
BenchmarkJobKind,
1020
} from "./data";
1121
import CommitSha from "./commit-sha.vue";
1222
@@ -45,6 +55,12 @@ function formatJobStatus(status: BenchmarkJobStatus): string {
4555
return "Unknown";
4656
}
4757
}
58+
function formatJobKind(kind: BenchmarkJobKind): string {
59+
if (kind === "compiletime") {
60+
return "compile";
61+
}
62+
return kind;
63+
}
4864
4965
function ActiveStatus({collector}: {collector: CollectorConfig}) {
5066
const now = new Date();
@@ -101,6 +117,35 @@ function formatProfile(job: BenchmarkJob): string {
101117
return "";
102118
}
103119
}
120+
function timeSince(timestamp: string): string {
121+
const date = parseDateIsoStringOrNull(timestamp);
122+
if (date === null) {
123+
return "";
124+
}
125+
const now = new Date();
126+
const diffSeconds = differenceInSeconds(now, date);
127+
return formatSecondsAsDuration(diffSeconds);
128+
}
129+
130+
// Takes a date like `2025-09-10T08:22:47.161348Z` and shows just the time
131+
// portion (`08:22:47`).
132+
function formatTime(dateString: string | null): string {
133+
const date = parseDateIsoStringOrNull(dateString);
134+
if (date === null) {
135+
return "";
136+
}
137+
return format(date, "HH:mm:ss");
138+
}
139+
140+
function jobDuration(job: BenchmarkJob): string {
141+
if (!isJobComplete(job)) {
142+
return "";
143+
}
144+
const start = parseDateIsoStringOrNull(job.startedAt);
145+
const end = parseDateIsoStringOrNull(job.completedAt);
146+
const diff = differenceInSeconds(end, start);
147+
return `Job took ${formatSecondsAsDuration(diff)}`;
148+
}
104149
</script>
105150

106151
<template>
@@ -182,18 +227,18 @@ function formatProfile(job: BenchmarkJob): string {
182227
<template v-for="job in collector.jobs">
183228
<tr v-if="ACTIVE_FILTERS[job.status]">
184229
<td>
185-
<CommitSha :tag="job.requestTag"></CommitSha>
230+
<CommitSha :tag="job.requestTag" :truncate="true"></CommitSha>
186231
</td>
187232
<td>
188233
{{ formatJobStatus(job.status) }}
189234
</td>
190-
<td>
191-
{{ formatISODate(job.startedAt) }}
235+
<td :title="`Started ${timeSince(job.startedAt)} ago`">
236+
{{ formatTime(job.startedAt) }}
192237
</td>
193-
<td>
194-
{{ formatISODate(job.completedAt) }}
238+
<td :title="jobDuration(job)">
239+
{{ formatTime(job.completedAt) }}
195240
</td>
196-
<td>{{ job.kind }}</td>
241+
<td>{{ formatJobKind(job.kind) }}</td>
197242
<td>{{ formatBackend(job) }}</td>
198243
<td>
199244
{{ formatProfile(job) }}

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,32 +122,34 @@ function ExpectedCurrentRequestCompletion() {
122122
123123
const now = new Date();
124124
const diffSeconds = differenceInSeconds(estimatedCompleted, now);
125-
const prettyDisplay = formatSecondsAsDuration(diffSeconds);
126125
126+
let expectedEnd: string;
127+
if (diffSeconds >= 0) {
128+
let remainingSeconds = formatSecondsAsDuration(diffSeconds);
129+
expectedEnd = `expected to end in approximately ${remainingSeconds}`;
130+
} else {
131+
expectedEnd = "is running longer than expected";
132+
}
133+
134+
let kind = "PR";
135+
let link;
127136
if (req.requestType === "Release") {
128-
return (
129-
<span>
130-
Current Benchmark for{" "}
131-
<strong>
132-
<CommitSha tag={req.tag}></CommitSha>
133-
</strong>{" "}
134-
expected to end in approximately {prettyDisplay}
135-
</span>
136-
);
137+
link = <CommitSha tag={req.tag}></CommitSha>;
138+
kind = "";
137139
} else {
138140
const url = `https://github.com/rust-lang/rust/pull/${req.pr}`;
139-
return (
140-
<span>
141-
Current Benchmark for PR{" "}
142-
<strong>
143-
<a href={url} target="_blank">
144-
#{req.pr}
145-
</a>{" "}
146-
</strong>
147-
expected to end in approximately {prettyDisplay}
148-
</span>
141+
link = (
142+
<a href={url} target="_blank">
143+
#{req.pr}
144+
</a>
149145
);
150146
}
147+
148+
return (
149+
<span>
150+
Current benchmark for {kind} <strong>{link}</strong> {expectedEnd}.
151+
</span>
152+
);
151153
}
152154
153155
function PullRequestLink({request}: {request: BenchmarkRequest}) {

0 commit comments

Comments
 (0)