Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions site/frontend/src/pages/status/commit-sha.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script setup lang="ts">
import {computed} from "vue";
import {tagLooksLikeSha} from "./data";

const props = defineProps<{
tag: string;
truncate?: boolean;
}>();

const looksLikeSha = computed(() => props.tag.length === 40);
const looksLikeSha = computed(() => tagLooksLikeSha(props.tag));
</script>

<template>
Expand All @@ -14,7 +16,7 @@ const looksLikeSha = computed(() => props.tag.length === 40);
:title="tag"
:href="'https://github.com/rust-lang/rust/commit/' + tag"
>
{{ tag.substring(0, 13) }}
{{ truncate ? tag.substring(0, 13) : tag }}
</a>
<template v-else>
{{ tag }}
Expand Down
8 changes: 8 additions & 0 deletions site/frontend/src/pages/status/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ export type StatusResponse = {
export function isJobComplete(job: BenchmarkJob): boolean {
return job.status === "Failed" || job.status === "Success";
}

export function isRequestInProgress(req: BenchmarkRequest): boolean {
return req.status === "InProgress";
}

export function tagLooksLikeSha(tag: string): boolean {
return tag.length === 40;
}
61 changes: 58 additions & 3 deletions site/frontend/src/pages/status/page.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<script setup lang="tsx">
import {h, ref, Ref} from "vue";
import {differenceInSeconds} from "date-fns";

import {getJson} from "../../utils/requests";
import {STATUS_DATA_URL} from "../../urls";
import {withLoading} from "../../utils/loading";
import {formatISODate, formatSecondsAsDuration} from "../../utils/formatting";
import {
formatISODate,
formatSecondsAsDuration,
parseDateIsoStringOrNull,
} from "../../utils/formatting";
import {useExpandedStore} from "../../utils/expansion";
import {
BenchmarkRequest,
CollectorConfig,
isJobComplete,
isRequestInProgress,
StatusResponse,
} from "./data";
import Collector from "./collector.vue";
Expand Down Expand Up @@ -104,6 +110,46 @@ function getErrorsLength(errors: Dict<string>) {
return `${errorsLen} ${errorsLen > 1 ? "s" : ""}`;
}

function ExpectedCurrentRequestCompletion() {
const req = data.value.timeline.find(isRequestInProgress);
if (!req) return "";
if (!req.endEstimated) return "";
if (!req.completedAt) return "";
const estimatedCompleted = parseDateIsoStringOrNull(req.completedAt);
if (!estimatedCompleted) {
return null;
}

const now = new Date();
const diffSeconds = differenceInSeconds(estimatedCompleted, now);
const prettyDisplay = formatSecondsAsDuration(diffSeconds);

if (req.requestType === "Release") {
return (
<span>
Current Benchmark for{" "}
<strong>
<CommitSha tag={req.tag}></CommitSha>
</strong>{" "}
expected to end in approximately {prettyDisplay}
</span>
);
} else {
const url = `https://github.com/rust-lang/rust/pull/${req.pr}`;
return (
<span>
Current Benchmark for PR{" "}
<strong>
<a href={url} target="_blank">
#{req.pr}
</a>{" "}
</strong>
expected to end in approximately {prettyDisplay}
</span>
);
}
}

function PullRequestLink({request}: {request: BenchmarkRequest}) {
if (request.requestType === "Release") {
return "";
Expand Down Expand Up @@ -164,7 +210,12 @@ loadStatusData(loading);
<div class="status-page-wrapper">
<div class="timeline-wrapper">
<h1>Timeline</h1>
<strong>Times are local.</strong>
<span class="small-padding-bottom">
<strong>Times are local.</strong>
</span>
<span class="small-padding-bottom">
<ExpectedCurrentRequestCompletion />
</span>
<div style="margin-bottom: 10px">
Queue length: {{ data.queueLength }}
</div>
Expand All @@ -189,7 +240,7 @@ loadStatusData(loading);
<tr :class="getRequestRowClassName(req)">
<td><PullRequestLink :request="req" /></td>
<td>{{ req.requestType }}</td>
<td><CommitSha :tag="req.tag"></CommitSha></td>
<td><CommitSha :truncate="true" :tag="req.tag"></CommitSha></td>
<td>
{{ formatStatus(req)
}}{{
Expand Down Expand Up @@ -364,4 +415,8 @@ loadStatusData(loading);
grid-template-columns: repeat(auto-fill, minmax(800px, 1fr));
grid-gap: 20px;
}

.small-padding-bottom {
padding-bottom: 8px;
}
</style>
11 changes: 11 additions & 0 deletions site/frontend/src/utils/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ export function formatISODate(dateString?: string): string {
}
return "";
}

export function parseDateIsoStringOrNull(dateString?: string): Date | null {
if (dateString) {
try {
return parseISO(dateString);
} catch (e) {
return null;
}
}
return null;
}
Loading