build-logs: extract compute_runtime_secs helper; clamp runtime in js
This commit is contained in:
parent
008609d0e7
commit
aa96d76e73
2 changed files with 7 additions and 3 deletions
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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)?,
|
||||
|
|
|
|||
Loading…
Reference in a new issue