diff --git a/frontend/packages/dashboard/src/tabs.js b/frontend/packages/dashboard/src/tabs.js index 34b348f2..c822e739 100644 --- a/frontend/packages/dashboard/src/tabs.js +++ b/frontend/packages/dashboard/src/tabs.js @@ -1127,7 +1127,7 @@ window.marked = marked; const age = h.started_at ? fmtAgeSecs(nowUnix - h.started_at) + ' ago' : '?'; const runtimeSpan = h.runtime_secs != null - ? el('span', { class: 'build-logs-runtime meta' }, fmtDuration(h.runtime_secs)) + ? el('span', { class: 'build-logs-runtime meta' }, fmtDuration(Math.max(0, h.runtime_secs))) : h.started_at && !h.finished_at ? el('span', { class: 'build-logs-runtime meta', diff --git a/hive-c0re/src/build_logs.rs b/hive-c0re/src/build_logs.rs index 31fcafd4..1492dbd6 100644 --- a/hive-c0re/src/build_logs.rs +++ b/hive-c0re/src/build_logs.rs @@ -333,7 +333,7 @@ impl BuildLogs { .query_row(params![id], |r| { let started_at: i64 = r.get(4)?; let finished_at: Option = r.get(5)?; - let runtime_secs = finished_at.map(|f| f - started_at); + let runtime_secs = compute_runtime_secs(started_at, finished_at); Ok(BuildLogFull { header: BuildLogHeader { id: r.get(0)?, @@ -410,10 +410,14 @@ pub fn spawn_vacuum(coord: &Arc) { }); } +fn compute_runtime_secs(started_at: i64, finished_at: Option) -> Option { + finished_at.map(|f| f - started_at) +} + fn row_to_header(r: &rusqlite::Row) -> rusqlite::Result { let started_at: i64 = r.get(4)?; let finished_at: Option = r.get(5)?; - let runtime_secs = finished_at.map(|f| f - started_at); + let runtime_secs = compute_runtime_secs(started_at, finished_at); Ok(BuildLogHeader { id: r.get(0)?, agent: r.get(1)?,