build-logs: surface runtime_secs in header; show duration in dashboard row

This commit is contained in:
damocles 2026-06-01 17:26:38 +02:00 committed by mara
commit 26c9c13cf5
2 changed files with 30 additions and 4 deletions

View file

@ -96,6 +96,9 @@ pub struct BuildLogHeader {
pub started_at: i64,
pub finished_at: Option<i64>,
pub status: Option<String>,
/// Elapsed seconds from `started_at` to `finished_at`. `None` while
/// the build is still in progress.
pub runtime_secs: Option<i64>,
}
/// Full row with stdout/stderr text inlined. Returned by `get_full`,
@ -328,15 +331,19 @@ impl BuildLogs {
)?;
let row = stmt
.query_row(params![id], |r| {
let started_at: i64 = r.get(4)?;
let finished_at: Option<i64> = r.get(5)?;
let runtime_secs = finished_at.map(|f| f - started_at);
Ok(BuildLogFull {
header: BuildLogHeader {
id: r.get(0)?,
agent: r.get(1)?,
kind: r.get(2)?,
cmdline: r.get(3)?,
started_at: r.get(4)?,
finished_at: r.get(5)?,
started_at,
finished_at,
status: r.get(6)?,
runtime_secs,
},
stdout: r.get(7)?,
stderr: r.get(8)?,
@ -404,14 +411,18 @@ pub fn spawn_vacuum(coord: &Arc<crate::coordinator::Coordinator>) {
}
fn row_to_header(r: &rusqlite::Row) -> rusqlite::Result<BuildLogHeader> {
let started_at: i64 = r.get(4)?;
let finished_at: Option<i64> = r.get(5)?;
let runtime_secs = finished_at.map(|f| f - started_at);
Ok(BuildLogHeader {
id: r.get(0)?,
agent: r.get(1)?,
kind: r.get(2)?,
cmdline: r.get(3)?,
started_at: r.get(4)?,
finished_at: r.get(5)?,
started_at,
finished_at,
status: r.get(6)?,
runtime_secs,
})
}