@@ -3,7 +3,7 @@ import {getJson} from "../../utils/requests";
3
3
import {STATUS_DATA_URL } from " ../../urls" ;
4
4
import {withLoading } from " ../../utils/loading" ;
5
5
import {computed , ref , Ref } from " vue" ;
6
- import {StatusResponse } from " ./data" ;
6
+ import {Artifact , Commit , MissingReason , StatusResponse } from " ./data" ;
7
7
8
8
async function loadStatus(loading : Ref <boolean >) {
9
9
data .value = await withLoading (loading , () =>
@@ -28,20 +28,47 @@ function formatDuration(seconds: number): string {
28
28
return s ;
29
29
}
30
30
31
- function commitUrl(commit : {sha: string }): string {
32
- return ` <a href="https://github.com/rust-lang/rust/commit/${
33
- commit .sha
34
- }">${commit .sha .substring (0 , 13 )}</a> ` ;
31
+ function getArtifactPr(reason : MissingReason ): number {
32
+ if (reason .hasOwnProperty (" InProgress" )) {
33
+ return getArtifactPr (reason [" InProgress" ]);
34
+ } else if (reason .hasOwnProperty (" Master" )) {
35
+ return reason [" Master" ].pr ;
36
+ } else if (reason .hasOwnProperty (" Try" )) {
37
+ return reason [" Try" ].pr ;
38
+ } else {
39
+ throw new Error (` Unknown missing reason ${reason } ` );
40
+ }
35
41
}
36
42
37
- function formatArtifact(artifact : any ): string {
38
- if (artifact .Commit ) {
39
- return commitUrl (artifact .Commit );
43
+ function getArtifactSha(artifact : Artifact ): string {
44
+ if (artifact .hasOwnProperty (" Commit" )) {
45
+ return artifact [" Commit" ].sha ;
46
+ } else if (artifact .hasOwnProperty (" Tag" )) {
47
+ return artifact [" Tag" ];
40
48
} else {
41
- return artifact . Tag ;
49
+ throw new Error ( ` Unknown artifact ${ artifact } ` ) ;
42
50
}
43
51
}
44
52
53
+ function commitUrlAsHtml(sha : string ): string {
54
+ return ` <a href="https://github.com/rust-lang/rust/commit/${sha }">${sha .substring (
55
+ 0 ,
56
+ 13
57
+ )}</a> ` ;
58
+ }
59
+
60
+ function pullRequestUrlAsHtml(pr : number ): string {
61
+ return ` <a href="https://github.com/rust-lang/rust/pull/${pr }">#${pr }</a> ` ;
62
+ }
63
+
64
+ function formatCommitAsHtml(commit : Commit , reason : MissingReason ): string {
65
+ const url = commitUrlAsHtml (commit .sha );
66
+ const type = commit .type === " Try" ? " try" : " master" ;
67
+ const pr = getArtifactPr (reason );
68
+
69
+ return ` ${pullRequestUrlAsHtml (pr )} (${type }): ${url } ` ;
70
+ }
71
+
45
72
function formatReason(reason : any ): string {
46
73
if (typeof reason == " string" ) {
47
74
return reason ;
@@ -81,6 +108,20 @@ const timeLeft = computed(() => {
81
108
const recentEndDate = computed (() => {
82
109
return new Date (data .value .most_recent_end * 1000 );
83
110
});
111
+ const currentCommitAndReason: Ref <[Commit , MissingReason ] | null > = computed (
112
+ () => {
113
+ const current = data .value ?.current ?? null ;
114
+ if (current === null ) return null ;
115
+ const sha = getArtifactSha (current .artifact );
116
+
117
+ for (const [commit, reason] of data .value .missing ) {
118
+ if (commit .sha === sha && reason .hasOwnProperty (" InProgress" )) {
119
+ return [commit , reason [" InProgress" ]];
120
+ }
121
+ }
122
+ return null ;
123
+ }
124
+ );
84
125
85
126
const loading = ref (true );
86
127
@@ -94,7 +135,15 @@ loadStatus(loading);
94
135
<div v-if =" data.current !== null" >
95
136
<p >
96
137
Currently benchmarking:
97
- <span v-html =" formatArtifact(data.current.artifact)" ></span >.<br />
138
+ <span
139
+ v-html ="
140
+ formatCommitAsHtml(
141
+ currentCommitAndReason[0],
142
+ currentCommitAndReason[1]
143
+ )
144
+ "
145
+ ></span
146
+ >.<br />
98
147
Time left: {{ formatDuration(timeLeft) }}
99
148
</p >
100
149
<table >
@@ -164,7 +213,7 @@ loadStatus(loading);
164
213
<tbody >
165
214
<tr v-for =" [commit, reason] in data.missing" >
166
215
<td >{{ new Date(commit.date).toLocaleString() }}</td >
167
- <td v-html =" commitUrl (commit)" ></td >
216
+ <td v-html =" commitUrlAsHtml (commit.sha )" ></td >
168
217
<td v-html =" formatReason(reason)" ></td >
169
218
</tr >
170
219
</tbody >
0 commit comments