Skip to content

Commit c752f0e

Browse files
authored
Merge pull request #2319 from Jamesbarford/feat/display-current-request-expected-end-clearly
Show at the top of the timeline when the current benchmark is expected to finish
2 parents f81d441 + 3189dd3 commit c752f0e

File tree

4 files changed

+81
-5
lines changed

4 files changed

+81
-5
lines changed

site/frontend/src/pages/status/commit-sha.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<script setup lang="ts">
22
import {computed} from "vue";
3+
import {tagLooksLikeSha} from "./data";
34
45
const props = defineProps<{
56
tag: string;
7+
truncate?: boolean;
68
}>();
79
8-
const looksLikeSha = computed(() => props.tag.length === 40);
10+
const looksLikeSha = computed(() => tagLooksLikeSha(props.tag));
911
</script>
1012

1113
<template>
@@ -14,7 +16,7 @@ const looksLikeSha = computed(() => props.tag.length === 40);
1416
:title="tag"
1517
:href="'https://github.com/rust-lang/rust/commit/' + tag"
1618
>
17-
{{ tag.substring(0, 13) }}
19+
{{ truncate ? tag.substring(0, 13) : tag }}
1820
</a>
1921
<template v-else>
2022
{{ tag }}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ export type StatusResponse = {
4848
export function isJobComplete(job: BenchmarkJob): boolean {
4949
return job.status === "Failed" || job.status === "Success";
5050
}
51+
52+
export function isRequestInProgress(req: BenchmarkRequest): boolean {
53+
return req.status === "InProgress";
54+
}
55+
56+
export function tagLooksLikeSha(tag: string): boolean {
57+
return tag.length === 40;
58+
}

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<script setup lang="tsx">
22
import {h, ref, Ref} from "vue";
3+
import {differenceInSeconds} from "date-fns";
34
45
import {getJson} from "../../utils/requests";
56
import {STATUS_DATA_URL} from "../../urls";
67
import {withLoading} from "../../utils/loading";
7-
import {formatISODate, formatSecondsAsDuration} from "../../utils/formatting";
8+
import {
9+
formatISODate,
10+
formatSecondsAsDuration,
11+
parseDateIsoStringOrNull,
12+
} from "../../utils/formatting";
813
import {useExpandedStore} from "../../utils/expansion";
914
import {
1015
BenchmarkRequest,
1116
CollectorConfig,
1217
isJobComplete,
18+
isRequestInProgress,
1319
StatusResponse,
1420
} from "./data";
1521
import Collector from "./collector.vue";
@@ -104,6 +110,46 @@ function getErrorsLength(errors: Dict<string>) {
104110
return `${errorsLen} ${errorsLen > 1 ? "s" : ""}`;
105111
}
106112
113+
function ExpectedCurrentRequestCompletion() {
114+
const req = data.value.timeline.find(isRequestInProgress);
115+
if (!req) return "";
116+
if (!req.endEstimated) return "";
117+
if (!req.completedAt) return "";
118+
const estimatedCompleted = parseDateIsoStringOrNull(req.completedAt);
119+
if (!estimatedCompleted) {
120+
return null;
121+
}
122+
123+
const now = new Date();
124+
const diffSeconds = differenceInSeconds(estimatedCompleted, now);
125+
const prettyDisplay = formatSecondsAsDuration(diffSeconds);
126+
127+
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+
} else {
138+
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>
149+
);
150+
}
151+
}
152+
107153
function PullRequestLink({request}: {request: BenchmarkRequest}) {
108154
if (request.requestType === "Release") {
109155
return "";
@@ -164,7 +210,12 @@ loadStatusData(loading);
164210
<div class="status-page-wrapper">
165211
<div class="timeline-wrapper">
166212
<h1>Timeline</h1>
167-
<strong>Times are local.</strong>
213+
<span class="small-padding-bottom">
214+
<strong>Times are local.</strong>
215+
</span>
216+
<span class="small-padding-bottom">
217+
<ExpectedCurrentRequestCompletion />
218+
</span>
168219
<div style="margin-bottom: 10px">
169220
Queue length: {{ data.queueLength }}
170221
</div>
@@ -189,7 +240,7 @@ loadStatusData(loading);
189240
<tr :class="getRequestRowClassName(req)">
190241
<td><PullRequestLink :request="req" /></td>
191242
<td>{{ req.requestType }}</td>
192-
<td><CommitSha :tag="req.tag"></CommitSha></td>
243+
<td><CommitSha :truncate="true" :tag="req.tag"></CommitSha></td>
193244
<td>
194245
{{ formatStatus(req)
195246
}}{{
@@ -364,4 +415,8 @@ loadStatusData(loading);
364415
grid-template-columns: repeat(auto-fill, minmax(800px, 1fr));
365416
grid-gap: 20px;
366417
}
418+
419+
.small-padding-bottom {
420+
padding-bottom: 8px;
421+
}
367422
</style>

site/frontend/src/utils/formatting.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ export function formatISODate(dateString?: string): string {
2727
}
2828
return "";
2929
}
30+
31+
export function parseDateIsoStringOrNull(dateString?: string): Date | null {
32+
if (dateString) {
33+
try {
34+
return parseISO(dateString);
35+
} catch (e) {
36+
return null;
37+
}
38+
}
39+
return null;
40+
}

0 commit comments

Comments
 (0)