Skip to content

Commit 266038f

Browse files
committed
Include preparing tasks in submitted task state badge total
1 parent 6270e7f commit 266038f

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/components/cylc/TaskStateBadge.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
location="top"
2626
:open-delay="400"
2727
>
28-
{{ value }} {{ state }} task{{ value > 1 ? 's': '' }}.
28+
{{ value }} {{ displayName }} task{{ value > 1 ? 's': '' }}.
2929
<template v-if="latestTasks.length">
3030
Latest:
3131
<span
@@ -41,7 +41,9 @@
4141
</template>
4242

4343
<script setup>
44-
defineProps({
44+
import { computed } from 'vue'
45+
46+
const props = defineProps({
4547
state: {
4648
type: String,
4749
required: true
@@ -59,4 +61,8 @@ defineProps({
5961
default: 5,
6062
},
6163
})
64+
65+
const displayName = computed(
66+
() => props.state === 'submitted' ? 'preparing/submitted' : props.state
67+
)
6268
</script>

src/components/cylc/tree/GScanTreeItem.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ function getStatesInfo (node, stateTotals = {}, latestTasks = {}) {
117117
118118
// the non-zero state totals from this node with all the others from the tree
119119
for (const state of taskStatesOrdered) {
120-
const nodeTotal = node.node.stateTotals[state]
120+
let nodeTotal = node.node.stateTotals[state]
121+
const nodeLatestTasks = Array.from(node.node.latestStateTasks?.[state] ?? [])
122+
if (state === TaskState.SUBMITTED.name) { // include preparing tasks
123+
nodeTotal += node.node.stateTotals.preparing
124+
nodeLatestTasks.push(...(node.node.latestStateTasks?.preparing ?? []))
125+
}
121126
if (nodeTotal) {
122127
stateTotals[state] = (stateTotals[state] ?? 0) + nodeTotal
123128
}
124-
const nodeLatestTasks = node.node.latestStateTasks?.[state]
125-
if (nodeLatestTasks?.length) {
129+
if (nodeLatestTasks.length) {
126130
latestTasks[state] = [
127131
...(latestTasks[state] ?? []),
128132
...nodeLatestTasks,

tests/unit/components/cylc/tree/treeitem.vue.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('GScanTreeItem', () => {
152152
}
153153
})
154154
it('combines all descendant tasks', () => {
155-
expect(wrapper.vm.statesInfo.latestTasks.submitted.length).to.equal(10)
155+
expect(wrapper.vm.statesInfo.latestTasks.submitted.length).to.equal(20)
156156
expect(wrapper.vm.statesInfo.latestTasks.running.length).to.equal(10)
157157
})
158158
it('combines all descendant task totals', () => {

0 commit comments

Comments
 (0)