address review: switch hive-c0re to hive-jobq-wire's shared parse_states/filter_nodes_by_state, note the generic shape in endpoint docs
This commit is contained in:
parent
08efd7875e
commit
eae04ac2c5
3 changed files with 29 additions and 108 deletions
|
|
@ -351,15 +351,16 @@ impl JobQueue {
|
|||
/// still-matching descendant one level higher rather than hiding or
|
||||
/// orphaning it.
|
||||
///
|
||||
/// The projection itself is [`hive_jobq_wire`]'s; all this layer supplies
|
||||
/// is *which* nodes to show — see [`visible_roots`] for why the graph
|
||||
/// can't decide the root-visibility half of that for itself.
|
||||
/// The projection and state filter are both [`hive_jobq_wire`]'s; this
|
||||
/// layer only supplies *which roots* are in view (see [`visible_roots`]
|
||||
/// for why the graph can't decide that itself) — an older, different
|
||||
/// question than state filtering, and neither replaces the other.
|
||||
#[must_use]
|
||||
pub fn graph_snapshot(&self, states: Option<&[State]>) -> Vec<GraphNode> {
|
||||
let inner = self.lock();
|
||||
let roots = visible_roots(&inner);
|
||||
let nodes = inner.graph().wire_snapshot(roots);
|
||||
filter_nodes_by_state(nodes, states)
|
||||
hive_jobq_wire::filter_nodes_by_state(nodes, states)
|
||||
}
|
||||
|
||||
/// Per-state counts over the **same** groups [`JobQueue::graph_snapshot`]
|
||||
|
|
@ -414,26 +415,6 @@ fn find_node(sched: &Sched, id: u64) -> Option<NodeId> {
|
|||
.find_map(|n| (n.id.get() == id).then_some(n.id))
|
||||
}
|
||||
|
||||
/// [`JobQueue::graph_snapshot`]'s `states` ask, applied to the already-
|
||||
/// projected node list: keeps every node — root or descendant — whose own
|
||||
/// `state` is named.
|
||||
///
|
||||
/// Applied *after* [`GraphWire::wire_snapshot`] rather than as a root
|
||||
/// pre-filter — narrowing which roots are visible at all is
|
||||
/// [`visible_roots`]'s job (a different question: how much settled work is
|
||||
/// retained, full stop); this is "of what's retained and live, which
|
||||
/// individual nodes does the caller want shown right now." `None` (or an
|
||||
/// unrecognised/absent query) is the identity filter.
|
||||
fn filter_nodes_by_state(nodes: Vec<GraphNode>, states: Option<&[State]>) -> Vec<GraphNode> {
|
||||
let Some(states) = states else {
|
||||
return nodes;
|
||||
};
|
||||
nodes
|
||||
.into_iter()
|
||||
.filter(|n| states.contains(&n.state))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The visible **group** set for [`JobQueue::graph_snapshot`]: every live group
|
||||
/// root, plus the newest [`MAX_HISTORY_DAGS`] settled ones.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue