Skip to content

Commit ce83d3c

Browse files
authored
Merge pull request #1741 from Kobzol/redesign-status-page-2
Redesign status page (take 2)
2 parents 099e48b + 74f0396 commit ce83d3c

File tree

12 files changed

+618
-191
lines changed

12 files changed

+618
-191
lines changed

database/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ pub struct CompileBenchmark {
710710

711711
#[derive(Debug)]
712712
pub struct ArtifactCollection {
713+
pub artifact: ArtifactId,
713714
pub duration: Duration,
714715
pub end_time: DateTime<Utc>,
715716
}

database/src/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub trait Connection: Send + Sync {
158158

159159
async fn in_progress_steps(&self, aid: &ArtifactId) -> Vec<Step>;
160160

161-
async fn last_artifact_collection(&self) -> Option<ArtifactCollection>;
161+
async fn last_n_artifact_collections(&self, n: u32) -> Vec<ArtifactCollection>;
162162

163163
/// Returns the sha of the parent commit, if available.
164164
///

database/src/pool/postgres.rs

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,21 +1216,31 @@ where
12161216
})
12171217
.collect()
12181218
}
1219-
async fn last_artifact_collection(&self) -> Option<ArtifactCollection> {
1219+
async fn last_n_artifact_collections(&self, n: u32) -> Vec<ArtifactCollection> {
12201220
self.conn()
1221-
.query_opt(
1222-
"select date_recorded, duration \
1223-
from artifact_collection_duration \
1221+
.query(
1222+
"select art.name, art.date, art.type, acd.date_recorded, acd.duration \
1223+
from artifact_collection_duration as acd \
1224+
join artifact as art on art.id = acd.aid \
12241225
order by date_recorded desc \
1225-
limit 1;",
1226-
&[],
1226+
limit $1;",
1227+
&[&(n as i64)],
12271228
)
12281229
.await
12291230
.unwrap()
1230-
.map(|r| ArtifactCollection {
1231-
end_time: r.get(0),
1232-
duration: Duration::from_secs(r.get::<_, i32>(1) as u64),
1231+
.into_iter()
1232+
.map(|r| {
1233+
let sha = r.get::<_, String>(0);
1234+
let date = r.get::<_, Option<DateTime<Utc>>>(1);
1235+
let ty = r.get::<_, String>(2);
1236+
1237+
ArtifactCollection {
1238+
artifact: parse_artifact_id(&ty, &sha, date),
1239+
end_time: r.get(3),
1240+
duration: Duration::from_secs(r.get::<_, i32>(4) as u64),
1241+
}
12331242
})
1243+
.collect()
12341244
}
12351245
async fn parent_of(&self, sha: &str) -> Option<String> {
12361246
self.conn()
@@ -1374,23 +1384,7 @@ where
13741384
.unwrap()?;
13751385
let date = row.get::<_, Option<DateTime<Utc>>>(0);
13761386
let ty = row.get::<_, String>(1);
1377-
1378-
match ty.as_str() {
1379-
"master" => Some(ArtifactId::Commit(Commit {
1380-
sha: artifact.to_owned(),
1381-
date: Date(date.expect("date present for master commits")),
1382-
r#type: CommitType::Master,
1383-
})),
1384-
"try" => Some(ArtifactId::Commit(Commit {
1385-
sha: artifact.to_owned(),
1386-
date: date
1387-
.map(Date)
1388-
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1389-
r#type: CommitType::Try,
1390-
})),
1391-
"release" => Some(ArtifactId::Tag(artifact.to_owned())),
1392-
_ => panic!("unknown artifact type: {:?}", ty),
1393-
}
1387+
Some(parse_artifact_id(&ty, artifact, date))
13941388
}
13951389

13961390
async fn purge_artifact(&self, aid: &ArtifactId) {
@@ -1403,3 +1397,22 @@ where
14031397
.unwrap();
14041398
}
14051399
}
1400+
1401+
fn parse_artifact_id(ty: &str, sha: &str, date: Option<DateTime<Utc>>) -> ArtifactId {
1402+
match ty {
1403+
"master" => ArtifactId::Commit(Commit {
1404+
sha: sha.to_owned(),
1405+
date: Date(date.expect("date present for master commits")),
1406+
r#type: CommitType::Master,
1407+
}),
1408+
"try" => ArtifactId::Commit(Commit {
1409+
sha: sha.to_owned(),
1410+
date: date
1411+
.map(Date)
1412+
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1413+
r#type: CommitType::Try,
1414+
}),
1415+
"release" => ArtifactId::Tag(sha.to_owned()),
1416+
_ => panic!("unknown artifact type: {:?}", ty),
1417+
}
1418+
}

database/src/pool/sqlite.rs

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -577,25 +577,7 @@ impl Connection for SqliteConnection {
577577
.optional()
578578
.unwrap()?;
579579

580-
match ty.as_str() {
581-
"master" => Some(ArtifactId::Commit(Commit {
582-
sha: artifact.to_owned(),
583-
date: Date(
584-
Utc.timestamp_opt(date.expect("master has date"), 0)
585-
.unwrap(),
586-
),
587-
r#type: CommitType::Master,
588-
})),
589-
"try" => Some(ArtifactId::Commit(Commit {
590-
sha: artifact.to_owned(),
591-
date: date
592-
.map(|d| Date(Utc.timestamp_opt(d, 0).unwrap()))
593-
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
594-
r#type: CommitType::Try,
595-
})),
596-
"release" => Some(ArtifactId::Tag(artifact.to_owned())),
597-
_ => panic!("unknown artifact type: {:?}", ty),
598-
}
580+
Some(parse_artifact_id(ty.as_str(), artifact, date))
599581
}
600582

601583
async fn record_duration(&self, artifact: ArtifactIdNumber, duration: Duration) {
@@ -1166,24 +1148,31 @@ impl Connection for SqliteConnection {
11661148
.collect()
11671149
}
11681150

1169-
async fn last_artifact_collection(&self) -> Option<ArtifactCollection> {
1151+
async fn last_n_artifact_collections(&self, n: u32) -> Vec<ArtifactCollection> {
11701152
self.raw_ref()
1171-
.query_row(
1172-
"select date_recorded, duration \
1173-
from artifact_collection_duration \
1153+
.prepare_cached(
1154+
"select art.name, art.date, art.type, acd.date_recorded, acd.duration \
1155+
from artifact_collection_duration as acd \
1156+
join artifact as art on art.id = acd.aid \
11741157
order by date_recorded desc \
1175-
limit 1;",
1176-
params![],
1177-
|r| {
1178-
Ok((
1179-
Utc.timestamp_opt(r.get(0)?, 0).unwrap(),
1180-
Duration::from_secs(r.get(1)?),
1181-
))
1182-
},
1158+
limit ?;",
11831159
)
1184-
.optional()
11851160
.unwrap()
1186-
.map(|(end_time, duration)| ArtifactCollection { end_time, duration })
1161+
.query(params![&n])
1162+
.unwrap()
1163+
.mapped(|r| {
1164+
let sha = r.get::<_, String>(0)?;
1165+
let date = r.get::<_, Option<i64>>(1)?;
1166+
let ty = r.get::<_, String>(2)?;
1167+
1168+
Ok(ArtifactCollection {
1169+
artifact: parse_artifact_id(&ty, &sha, date),
1170+
end_time: Utc.timestamp_opt(r.get(3)?, 0).unwrap(),
1171+
duration: Duration::from_secs(r.get(4)?),
1172+
})
1173+
})
1174+
.collect::<Result<Vec<_>, _>>()
1175+
.unwrap()
11871176
}
11881177

11891178
async fn parent_of(&self, sha: &str) -> Option<String> {
@@ -1252,3 +1241,25 @@ impl Connection for SqliteConnection {
12521241
.unwrap();
12531242
}
12541243
}
1244+
1245+
fn parse_artifact_id(ty: &str, sha: &str, date: Option<i64>) -> ArtifactId {
1246+
match ty {
1247+
"master" => ArtifactId::Commit(Commit {
1248+
sha: sha.to_owned(),
1249+
date: Date(
1250+
Utc.timestamp_opt(date.expect("master has date"), 0)
1251+
.unwrap(),
1252+
),
1253+
r#type: CommitType::Master,
1254+
}),
1255+
"try" => ArtifactId::Commit(Commit {
1256+
sha: sha.to_owned(),
1257+
date: date
1258+
.map(|d| Date(Utc.timestamp_opt(d, 0).unwrap()))
1259+
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1260+
r#type: CommitType::Try,
1261+
}),
1262+
"release" => ArtifactId::Tag(sha.to_owned()),
1263+
_ => panic!("unknown artifact type: {:?}", ty),
1264+
}
1265+
}

site/frontend/package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"vue-tsc": "^1.8.3"
2121
},
2222
"dependencies": {
23+
"date-fns": "^2.30.0",
2324
"highcharts": "6.0.7",
2425
"msgpack-lite": "^0.1.26",
2526
"parcel": "^2.8.3",
Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
interface Commit {
1+
export interface Commit {
22
sha: string;
33
date: string;
44
type: "Try" | "Master";
55
}
66

7-
interface BenchmarkStatus {
7+
export interface BenchmarkError {
88
name: string;
99
error: string;
1010
}
@@ -16,20 +16,50 @@ interface Step {
1616
current_progress: number;
1717
}
1818

19-
/**
20-
* The `any` types in the interface below were chosen because the types are quite complex
21-
* on the Rust side (they are modeled with enums encoded in a way that is not so simple to model in
22-
* TS).
23-
*/
19+
export type Artifact =
20+
| {
21+
Commit: Commit;
22+
}
23+
| {
24+
Tag: string;
25+
};
26+
27+
export type MissingReason =
28+
| {
29+
Master: {
30+
pr: number;
31+
parent_sha: string;
32+
is_try_parent: boolean;
33+
};
34+
}
35+
| {
36+
Try: {
37+
pr: number;
38+
parent_sha: string;
39+
include: string | null;
40+
exclude: string | null;
41+
runs: number | null;
42+
};
43+
}
44+
| {
45+
InProgress: MissingReason;
46+
};
47+
2448
interface CurrentState {
25-
artifact: any;
49+
artifact: Artifact;
2650
progress: Step[];
2751
}
2852

53+
export interface FinishedRun {
54+
artifact: Artifact;
55+
pr: number | null;
56+
errors: BenchmarkError[];
57+
duration: number;
58+
finished_at: number;
59+
}
60+
2961
export interface StatusResponse {
30-
last_commit: Commit | null;
31-
benchmarks: BenchmarkStatus[];
32-
missing: Array<[Commit, any]>;
62+
finished_runs: FinishedRun[];
3363
current: CurrentState | null;
34-
most_recent_end: number | null;
64+
missing: Array<[Commit, MissingReason]>;
3565
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {ref} from "vue";
2+
3+
export function useExpandedStore() {
4+
const expanded = ref(new Set());
5+
6+
function isExpanded(sha: string) {
7+
return expanded.value.has(sha);
8+
}
9+
10+
function toggleExpanded(sha: string) {
11+
if (isExpanded(sha)) {
12+
expanded.value.delete(sha);
13+
} else {
14+
expanded.value.add(sha);
15+
}
16+
}
17+
18+
return {toggleExpanded, isExpanded};
19+
}

0 commit comments

Comments
 (0)