Skip to content

Commit ea1484a

Browse files
committed
PR feedback; moved time formatting function, reverted JSX change
1 parent f7da5a5 commit ea1484a

File tree

3 files changed

+27
-45
lines changed

3 files changed

+27
-45
lines changed

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {getJson} from "../../utils/requests";
33
import {STATUS_DATA_URL} from "../../urls";
44
import {withLoading} from "../../utils/loading";
5+
import {formatDuration} from "../../utils/formatting";
56
import {computed, ref, Ref} from "vue";
67
import {
78
Artifact,
@@ -26,23 +27,6 @@ async function loadStatus(loading: Ref<boolean>) {
2627
);
2728
}
2829
29-
function formatDuration(seconds: number): string {
30-
let secs = seconds % 60;
31-
let mins = Math.trunc(seconds / 60);
32-
let hours = Math.trunc(mins / 60);
33-
mins -= hours * 60;
34-
35-
let s = "";
36-
if (hours > 0) {
37-
s = `${hours}h ${mins < 10 ? "0" + mins : mins}m ${
38-
secs < 10 ? "0" + secs : secs
39-
}s`;
40-
} else {
41-
s = `${mins < 10 ? " " + mins : mins}m ${secs < 10 ? "0" + secs : secs}s`;
42-
}
43-
return s;
44-
}
45-
4630
function getArtifactPr(reason: MissingReason): number {
4731
if (reason.hasOwnProperty("InProgress")) {
4832
return getArtifactPr(reason["InProgress"]);

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

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {ref, Ref} from "vue";
44
import {getJson} from "../../utils/requests";
55
import {STATUS_DATA_NEW_URL} from "../../urls";
66
import {withLoading} from "../../utils/loading";
7+
import {formatDuration} from "../../utils/formatting";
78
import {
89
StatusResponse,
910
CollectorJobMap,
@@ -28,33 +29,11 @@ const dataNew: Ref<
2829
(StatusResponse & {collectorJobMap: CollectorJobMap}) | null
2930
> = ref(null);
3031
31-
function PullRequestLink({request}: {request: BenchmarkRequestType}) {
32-
if (request.type === ReleaseCommit) {
32+
function pullRequestUrlAsHtml(reqType: BenchmarkRequestType): string {
33+
if (reqType.type === ReleaseCommit) {
3334
return "";
3435
}
35-
return (
36-
<a href={`https://github.com/rust-lang/rust/pull/${request.pr}`}>
37-
#{request.pr}
38-
</a>
39-
);
40-
}
41-
42-
function formatDuration(milliseconds: number): string {
43-
let seconds = milliseconds / 1000;
44-
let secs = seconds % 60;
45-
let mins = Math.trunc(seconds / 60);
46-
let hours = Math.trunc(mins / 60);
47-
mins -= hours * 60;
48-
49-
let s = "";
50-
if (hours > 0) {
51-
s = `${hours}h ${mins < 10 ? "0" + mins : mins}m ${
52-
secs < 10 ? "0" + secs : secs
53-
}s`;
54-
} else {
55-
s = `${mins < 10 ? " " + mins : mins}m ${secs < 10 ? "0" + secs : secs}s`;
56-
}
57-
return s;
36+
return `<a href="https://github.com/rust-lang/rust/pull/${reqType.pr}">#${reqType.pr}</a>`;
5837
}
5938
6039
loadStatusNew(loading);
@@ -81,13 +60,15 @@ loadStatusNew(loading);
8160
<tbody>
8261
<template v-for="req in dataNew.completed">
8362
<tr>
84-
<td><PullRequestLink :request="req.requestType" /></td>
63+
<td v-html="pullRequestUrlAsHtml(req.requestType)"></td>
8564
<td>{{ req.requestType.type }}</td>
8665
<td>{{ req.requestType.tag }}</td>
8766
<td>{{ req.status.state }}</td>
8867
<td>{{ req.status.completedAt }}</td>
8968
<td v-html="formatDuration(req.status.duration)"></td>
90-
<td>{{ req.errors.join("\n") }}</td>
69+
<td>
70+
<pre>{{ req.errors.join("\n") }}</pre>
71+
</td>
9172
</tr>
9273
</template>
9374
</tbody>
@@ -107,7 +88,7 @@ loadStatusNew(loading);
10788
<tbody>
10889
<template v-for="req in dataNew.queue">
10990
<tr>
110-
<td><PullRequestLink :request="req.requestType" /></td>
91+
<td v-html="pullRequestUrlAsHtml(req.requestType)"></td>
11192
<td>{{ req.requestType.type }}</td>
11293
<td>{{ req.requestType.tag }}</td>
11394
<td>{{ req.status.state }}</td>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export function formatDuration(milliseconds: number): string {
2+
let seconds = milliseconds / 1000;
3+
let secs = seconds % 60;
4+
let mins = Math.trunc(seconds / 60);
5+
let hours = Math.trunc(mins / 60);
6+
mins -= hours * 60;
7+
8+
let s = "";
9+
if (hours > 0) {
10+
s = `${hours}h ${mins < 10 ? "0" + mins : mins}m ${
11+
secs < 10 ? "0" + secs : secs
12+
}s`;
13+
} else {
14+
s = `${mins < 10 ? " " + mins : mins}m ${secs < 10 ? "0" + secs : secs}s`;
15+
}
16+
return s;
17+
}

0 commit comments

Comments
 (0)