Skip to content

Commit 46504f8

Browse files
workflows: omit stopped workflows from cumulative state totals (#2339)
1 parent 3e2ac32 commit 46504f8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

changes.d/2339.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In the sidebar, don't include task states for stopped workflows in any parent state totals.

src/components/cylc/tree/GScanTreeItem.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,26 @@ import { useWorkflowWarnings } from '@/composables/localStorage'
109109
* @param {Object} node
110110
* @param {Record<string, number>} stateTotals
111111
* @param {Record<string, string[]>} latestTasks
112+
* @param {Boolean} topLevel - true if the traversal depth is 0, else false.
112113
*/
113-
function traverseChildren (node, stateTotals = {}, latestTasks = {}) {
114+
function traverseChildren (node, stateTotals = {}, latestTasks = {}, topLevel = true) {
114115
// if we aren't at the end of the node tree, continue recurse until we hit something other then a workflow part
115116
if (node.type === 'workflow-part' && node.children) {
116117
// at every branch, recurse all child nodes
117118
for (const child of node.children) {
118-
traverseChildren(child, stateTotals, latestTasks)
119+
traverseChildren(child, stateTotals, latestTasks, false)
119120
}
120121
} else if (node.type === 'workflow' && node.node.stateTotals) {
121122
// if we are at the end of a node (or at least, hit a workflow node), stop and merge state
122123
123124
// the latest state tasks from this node with all the others from the tree
124125
for (const [state, totals] of Object.entries(node.node.stateTotals)) {
125-
if (JobStateNames.includes(state)) { // filter only valid states
126+
if (
127+
// filter only valid states
128+
JobStateNames.includes(state) &&
129+
// omit state totals from stopped workflows
130+
(topLevel || node.node.status !== 'stopped')
131+
) {
126132
// (cast as numbers so they dont get concatenated as strings)
127133
stateTotals[state] = (stateTotals[state] ?? 0) + parseInt(totals)
128134
}

0 commit comments

Comments
 (0)