Skip to content

Commit a29b1ec

Browse files
committed
PR Feedback; format to relative dates for when the benchmark is expected to complete
1 parent 69f1509 commit a29b1ec

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
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,
@@ -110,14 +115,22 @@ function ExpectedCurrentRequestCompletion() {
110115
if (!req) return "";
111116
if (!req.endEstimated) return "";
112117
if (!req.completedAt) return "";
113-
const formattedDate = formatISODate(req.completedAt);
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+
114127
return (
115128
<span>
116129
Current Benchmark for{" "}
117130
<strong>
118131
<CommitSha tag={req.tag}></CommitSha>
119132
</strong>{" "}
120-
expected to end at {formattedDate}{" "}
133+
expected to end in approximately {prettyDisplay}
121134
</span>
122135
);
123136
}

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)