Skip to content

Commit 2db0c66

Browse files
committed
Redesign status page
1 parent 7bcf41b commit 2db0c66

File tree

12 files changed

+541
-188
lines changed

12 files changed

+541
-188
lines changed

database/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ pub struct CompileBenchmark {
682682

683683
#[derive(Debug)]
684684
pub struct ArtifactCollection {
685+
pub artifact: ArtifactId,
685686
pub duration: Duration,
686687
pub end_time: DateTime<Utc>,
687688
}

database/src/pool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub trait Connection: Send + Sync {
156156

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

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

161161
/// Returns the sha of the parent commit, if available.
162162
///

database/src/pool/postgres.rs

+38-25
Original file line numberDiff line numberDiff line change
@@ -1211,21 +1211,31 @@ where
12111211
})
12121212
.collect()
12131213
}
1214-
async fn last_artifact_collection(&self) -> Option<ArtifactCollection> {
1214+
async fn last_n_artifact_collections(&self, n: u32) -> Vec<ArtifactCollection> {
12151215
self.conn()
1216-
.query_opt(
1217-
"select date_recorded, duration \
1218-
from artifact_collection_duration \
1216+
.query(
1217+
"select art.name, art.date, art.type, acd.date_recorded, acd.duration \
1218+
from artifact_collection_duration as acd \
1219+
join artifact as art on art.id = acd.aid \
12191220
order by date_recorded desc \
1220-
limit 1;",
1221-
&[],
1221+
limit $1;",
1222+
&[&n],
12221223
)
12231224
.await
12241225
.unwrap()
1225-
.map(|r| ArtifactCollection {
1226-
end_time: r.get(0),
1227-
duration: Duration::from_secs(r.get::<_, i32>(1) as u64),
1226+
.into_iter()
1227+
.map(|r| {
1228+
let sha = r.get::<_, String>(0);
1229+
let date = r.get::<_, Option<DateTime<Utc>>>(1);
1230+
let ty = r.get::<_, String>(2);
1231+
1232+
ArtifactCollection {
1233+
artifact: parse_artifact_id(&ty, &sha, date),
1234+
end_time: r.get(3),
1235+
duration: Duration::from_secs(r.get::<_, i32>(4) as u64),
1236+
}
12281237
})
1238+
.collect()
12291239
}
12301240
async fn parent_of(&self, sha: &str) -> Option<String> {
12311241
self.conn()
@@ -1369,22 +1379,25 @@ where
13691379
.unwrap()?;
13701380
let date = row.get::<_, Option<DateTime<Utc>>>(0);
13711381
let ty = row.get::<_, String>(1);
1382+
Some(parse_artifact_id(&ty, artifact, date))
1383+
}
1384+
}
13721385

1373-
match ty.as_str() {
1374-
"master" => Some(ArtifactId::Commit(Commit {
1375-
sha: artifact.to_owned(),
1376-
date: Date(date.expect("date present for master commits")),
1377-
r#type: CommitType::Master,
1378-
})),
1379-
"try" => Some(ArtifactId::Commit(Commit {
1380-
sha: artifact.to_owned(),
1381-
date: date
1382-
.map(Date)
1383-
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1384-
r#type: CommitType::Try,
1385-
})),
1386-
"release" => Some(ArtifactId::Tag(artifact.to_owned())),
1387-
_ => panic!("unknown artifact type: {:?}", ty),
1388-
}
1386+
fn parse_artifact_id(ty: &str, sha: &str, date: Option<DateTime<Utc>>) -> ArtifactId {
1387+
match ty {
1388+
"master" => ArtifactId::Commit(Commit {
1389+
sha: sha.to_owned(),
1390+
date: Date(date.expect("date present for master commits")),
1391+
r#type: CommitType::Master,
1392+
}),
1393+
"try" => ArtifactId::Commit(Commit {
1394+
sha: sha.to_owned(),
1395+
date: date
1396+
.map(Date)
1397+
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1398+
r#type: CommitType::Try,
1399+
}),
1400+
"release" => ArtifactId::Tag(sha.to_owned()),
1401+
_ => panic!("unknown artifact type: {:?}", ty),
13891402
}
13901403
}

database/src/pool/sqlite.rs

+44-33
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) {
@@ -1162,24 +1144,31 @@ impl Connection for SqliteConnection {
11621144
.collect()
11631145
}
11641146

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

11851174
async fn parent_of(&self, sha: &str) -> Option<String> {
@@ -1239,3 +1228,25 @@ impl Connection for SqliteConnection {
12391228
.unwrap()
12401229
}
12411230
}
1231+
1232+
fn parse_artifact_id(ty: &str, sha: &str, date: Option<i64>) -> ArtifactId {
1233+
match ty {
1234+
"master" => ArtifactId::Commit(Commit {
1235+
sha: sha.to_owned(),
1236+
date: Date(
1237+
Utc.timestamp_opt(date.expect("master has date"), 0)
1238+
.unwrap(),
1239+
),
1240+
r#type: CommitType::Master,
1241+
}),
1242+
"try" => ArtifactId::Commit(Commit {
1243+
sha: sha.to_owned(),
1244+
date: date
1245+
.map(|d| Date(Utc.timestamp_opt(d, 0).unwrap()))
1246+
.unwrap_or_else(|| Date::ymd_hms(2000, 1, 1, 0, 0, 0)),
1247+
r#type: CommitType::Try,
1248+
}),
1249+
"release" => ArtifactId::Tag(sha.to_owned()),
1250+
_ => panic!("unknown artifact type: {:?}", ty),
1251+
}
1252+
}

site/frontend/package-lock.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/frontend/package.json

+1
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",

site/frontend/src/pages/status/data.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface Commit {
44
type: "Try" | "Master";
55
}
66

7-
interface BenchmarkStatus {
7+
export interface BenchmarkError {
88
name: string;
99
error: string;
1010
}
@@ -50,10 +50,16 @@ interface CurrentState {
5050
progress: Step[];
5151
}
5252

53+
export interface FinishedRun {
54+
artifact: Artifact;
55+
pr: number | null;
56+
errors: BenchmarkError[];
57+
duration: number;
58+
finished_at: number;
59+
}
60+
5361
export interface StatusResponse {
54-
last_commit: Commit | null;
55-
benchmarks: BenchmarkStatus[];
56-
missing: Array<[Commit, MissingReason]>;
62+
finished_runs: FinishedRun[];
5763
current: CurrentState | null;
58-
most_recent_end: number | null;
64+
missing: Array<[Commit, MissingReason]>;
5965
}
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)