refactor(#2591): DagView carries host-computed timestamps + NodeView.has_log
Reconcile with mara + argus's review on the frontend PR (#2660): - DagView regains started_at/finished_at (DateTime<Utc>), computed host-side as min/max over ALL subtree nodes (including the Done ones filtered off the wire). The client can't derive these — the earliest/only-started node is often Done and absent — so the backend sets them, per mara's call. - NodeView gains has_log: bool = build_log_id.is_some(), the precise old 'node has a captured build log' guard so the dashboard only shows a log link for nodes that actually produce one.
This commit is contained in:
parent
f3207ce9f8
commit
02e2bf895e
2 changed files with 34 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ mod tests;
|
|||
use std::collections::HashMap;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use hive_jobq::resources::ResourceTable;
|
||||
use hive_jobq::scheduler::{Outcome, Scheduler};
|
||||
use hive_jobq::{Dep, DepWhen as JobDepWhen, Graph, NodeId, State as JobState};
|
||||
|
|
@ -758,10 +759,21 @@ impl QueueInner {
|
|||
fn dag_view(&self, container: NodeId) -> Option<DagView> {
|
||||
let meta = self.dag_meta(container)?;
|
||||
let mut nodes = Vec::new();
|
||||
// DAG-level timestamps are taken over *all* subtree nodes (including the
|
||||
// `Done` ones excluded from the wire) — the client can't derive them
|
||||
// from a `Done`-filtered node set, so the host computes them here.
|
||||
let mut started: Vec<DateTime<Utc>> = Vec::new();
|
||||
let mut finished: Vec<DateTime<Utc>> = Vec::new();
|
||||
for id in self.subtree(container) {
|
||||
let Some(node) = self.sched.graph().node(id) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(s) = node.started_at {
|
||||
started.push(s);
|
||||
}
|
||||
if let Some(f) = node.finished_at {
|
||||
finished.push(f);
|
||||
}
|
||||
if node.state == JobState::Done {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -782,6 +794,7 @@ impl QueueInner {
|
|||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let has_log = self.node_rt.get(&id).and_then(|r| r.build_log_id).is_some();
|
||||
nodes.push(NodeView {
|
||||
id: id.get(),
|
||||
agent: node.payload.agent().to_owned(),
|
||||
|
|
@ -793,16 +806,20 @@ impl QueueInner {
|
|||
error: node.error.clone(),
|
||||
approval_id,
|
||||
inputs,
|
||||
has_log,
|
||||
});
|
||||
}
|
||||
if nodes.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let is_terminal = self.dag_is_terminal(container);
|
||||
Some(DagView {
|
||||
id: container.get(),
|
||||
source: meta.source,
|
||||
reason: meta.reason.clone(),
|
||||
created_at: hive_sh4re::wire_time::from_secs(meta.created_at),
|
||||
started_at: started.into_iter().min(),
|
||||
finished_at: is_terminal.then(|| finished.into_iter().max()).flatten(),
|
||||
nodes,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue