Skip to content

Commit

Permalink
add build time to front page if available
Browse files Browse the repository at this point in the history
  • Loading branch information
DolceTriade committed Feb 1, 2024
1 parent 6d5643e commit f489581
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 14 deletions.
1 change: 1 addition & 0 deletions blade/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ rust_shared_library(
"@wasm_crate//:futures-util",
"@wasm_crate//:gloo-file",
"@wasm_crate//:gloo-net",
"@wasm_crate//:humantime",
"@wasm_crate//:junit-parser",
"@wasm_crate//:leptos",
"@wasm_crate//:leptos_meta",
Expand Down
23 changes: 17 additions & 6 deletions blade/bep/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ impl publish_build_event_server::PublishBuildEvent for BuildEventService {
session_uuid = uuid.clone();
log::info!("{}: Stream started", session_uuid);
if let Ok(mut db) = global.db_manager.as_ref().get() {
let _ = db.update_shallow_invocation(&session_uuid, Box::new(|i: &mut state::InvocationResults| {
i.status = state::Status::InProgress;
Ok(())
})).ok();
let _ = db
.update_shallow_invocation(
&session_uuid,
Box::new(|i: &mut state::InvocationResults| {
i.status = state::Status::InProgress;
Ok(())
}),
)
.ok();
}
}

Expand Down Expand Up @@ -191,7 +196,11 @@ impl publish_build_event_server::PublishBuildEvent for BuildEventService {
}))
.await
.map_err(|e| {
log::warn!("{}: failed to send message: {:#?}", session_uuid, e);
log::warn!(
"{}: failed to send message: {:#?}",
session_uuid,
e
);
build_ended = true;
});
if build_ended {
Expand All @@ -211,7 +220,9 @@ impl publish_build_event_server::PublishBuildEvent for BuildEventService {
global.db_manager.as_ref(),
&session_uuid,
)
.map_err(|e| log::error!("{session_uuid}: error closing stream: {e:#?}"));
.map_err(|e| {
log::error!("{session_uuid}: error closing stream: {e:#?}")
});
}
drop(tx);
return;
Expand Down
24 changes: 17 additions & 7 deletions blade/components/summaryheader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,25 @@ pub fn SummaryHeader() -> impl IntoView {
let cmd = with!(|invocation| ucfirst(&invocation.command));
let patterns = with!(|invocation| invocation.pattern.join(","));
let start = with!(|invocation| format_time(&invocation.start));
let duration = with!(|invocation| {
let Some(end) = invocation.end else {
return "".to_string();
};
let duration = end.duration_since(invocation.start).unwrap_or_default();
format!("Build Time: {}", humantime::format_duration(duration))
});
view! {
<div class="w-screen h-fit grid grid-rows-1 grid-flow-col items-center justify-center divide-x">
<div class="absolute flex gap-2 items-center">
<span class="text-lg">
<b>{cmd}</b>
</span>
<span>{patterns}</span>
<span>@</span>
<span class="text-grey-400 text-sm">{start}</span>
<div class="absolute">
<div class="flex gap-2 items-center">
<span class="text-lg">
<b>{cmd}</b>
</span>
<span class="inline-flex max-w-1/4 overflow-auto">{patterns}</span>
<span>@</span>
<span class="text-grey-400 text-sm">{start}</span>
</div>
<div class="flex gap-2 items-center">{duration}</div>
</div>
<div class="p-4">
<StatusIcon class="h-8 w-8" status=status.into()/>
Expand Down
4 changes: 4 additions & 0 deletions blade/db/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ impl state::DB for Postgres {
status: state::Status::parse(&res.status),
output: res.output,
start: crate::time::to_systemtime(&res.start)?,
end: res
.end
.as_ref()
.and_then(|t| crate::time::to_systemtime(t).ok()),
command: res.command,
pattern: res
.pattern
Expand Down
1 change: 1 addition & 0 deletions blade/db/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl state::DB for Sqlite {
status: state::Status::parse(&res.status),
output: res.output,
start: res.start.into(),
end: res.end.map(|t| t.into()),
command: res.command,
pattern: res
.pattern
Expand Down
37 changes: 36 additions & 1 deletion third_party/rust/WasmCargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "c39537dd5d0fd65ce4ffa37b2fba10d27a8284b9ba46041cd39686f2f4b78ca2",
"checksum": "86230726259f75c240a83704be13bc0bf61c349de4455148797f6f1f492b0c2f",
"crates": {
"addr2line 0.20.0": {
"name": "addr2line",
Expand Down Expand Up @@ -1721,6 +1721,10 @@
"id": "gloo-net 0.4.0",
"target": "gloo_net"
},
{
"id": "humantime 2.1.0",
"target": "humantime"
},
{
"id": "junit-parser 1.0.0",
"target": "junit_parser"
Expand Down Expand Up @@ -3596,6 +3600,36 @@
},
"license": "MIT OR Apache-2.0"
},
"humantime 2.1.0": {
"name": "humantime",
"version": "2.1.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/humantime/2.1.0/download",
"sha256": "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
}
},
"targets": [
{
"Library": {
"crate_name": "humantime",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "humantime",
"common_attrs": {
"compile_data_glob": [
"**"
],
"edition": "2018",
"version": "2.1.0"
},
"license": "MIT/Apache-2.0"
},
"hyper 0.14.27": {
"name": "hyper",
"version": "0.14.27",
Expand Down Expand Up @@ -11949,6 +11983,7 @@
"futures-util 0.3.29",
"gloo-file 0.3.0",
"gloo-net 0.4.0",
"humantime 2.1.0",
"junit-parser 1.0.0",
"leptos 0.5.4",
"leptos_meta 0.5.4",
Expand Down
7 changes: 7 additions & 0 deletions third_party/rust/WasmCargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions third_party/rust/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ def rust_dependencies():
version = "1.0.0",
features = ["serde"],
),
"humantime": crate.spec(
version = "2.1.0",
),
"time": crate.spec(
version = "0.3.31",
features = ["formatting", "macros"],
Expand Down

0 comments on commit f489581

Please sign in to comment.