build-logs: extract compute_runtime_secs helper; clamp runtime in js

This commit is contained in:
damocles 2026-06-01 17:38:21 +02:00 committed by mara
commit aa96d76e73
2 changed files with 7 additions and 3 deletions

View file

@ -333,7 +333,7 @@ impl BuildLogs {
.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);
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<crate::coordinator::Coordinator>) {
});
}
fn compute_runtime_secs(started_at: i64, finished_at: Option<i64>) -> Option<i64> {
finished_at.map(|f| f - started_at)
}
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);
let runtime_secs = compute_runtime_secs(started_at, finished_at);
Ok(BuildLogHeader {
id: r.get(0)?,
agent: r.get(1)?,