@@ -3,7 +3,7 @@ import {getJson} from "../../utils/requests";
33import {STATUS_DATA_URL } from " ../../urls" ;
44import {withLoading } from " ../../utils/loading" ;
55import {computed , ref , Ref } from " vue" ;
6- import {StatusResponse } from " ./data" ;
6+ import {Artifact , Commit , MissingReason , StatusResponse } from " ./data" ;
77
88async function loadStatus(loading : Ref <boolean >) {
99 data .value = await withLoading (loading , () =>
@@ -28,20 +28,47 @@ function formatDuration(seconds: number): string {
2828 return s ;
2929}
3030
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+ }
3541}
3642
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" ];
4048 } else {
41- return artifact . Tag ;
49+ throw new Error ( ` Unknown artifact ${ artifact } ` ) ;
4250 }
4351}
4452
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+
4572function formatReason(reason : any ): string {
4673 if (typeof reason == " string" ) {
4774 return reason ;
@@ -81,6 +108,20 @@ const timeLeft = computed(() => {
81108const recentEndDate = computed (() => {
82109 return new Date (data .value .most_recent_end * 1000 );
83110});
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+ );
84125
85126const loading = ref (true );
86127
@@ -94,7 +135,15 @@ loadStatus(loading);
94135 <div v-if =" data.current !== null" >
95136 <p >
96137 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 />
98147 Time left: {{ formatDuration(timeLeft) }}
99148 </p >
100149 <table >
@@ -164,7 +213,7 @@ loadStatus(loading);
164213 <tbody >
165214 <tr v-for =" [commit, reason] in data.missing" >
166215 <td >{{ new Date(commit.date).toLocaleString() }}</td >
167- <td v-html =" commitUrl (commit)" ></td >
216+ <td v-html =" commitUrlAsHtml (commit.sha )" ></td >
168217 <td v-html =" formatReason(reason)" ></td >
169218 </tr >
170219 </tbody >
0 commit comments