Skip to content

Commit cee1e6d

Browse files
continuation of fix to split family tree issue
1 parent 7b225b3 commit cee1e6d

File tree

4 files changed

+62
-56
lines changed

4 files changed

+62
-56
lines changed

src/services/mock/json/workflows/multi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"id": "~user/other/multi/run2//$namespace|root",
118118
"name": "root",
119119
"parents": [],
120+
"descendants": ["foo"],
120121
"childTasks": [
121122
{
122123
"name": "foo",

src/services/mock/json/workflows/one.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"id": "~user/one//$namespace|root",
5353
"name": "root",
5454
"parents": [],
55+
"descendants": ["BAD", "GOOD", "waiting", "sleepy", "checkpoint"],
5556
"childTasks": [
5657
{
5758
"name": "checkpoint",
@@ -81,12 +82,14 @@
8182
"__typename": "Family",
8283
"id": "~user/one//$namespace|BAD",
8384
"name": "BAD",
85+
"firstParent": { "id": "~user/one//$namespace|root", "name": "root"},
8486
"parents": [
8587
{
8688
"name": "root",
8789
"_typename": "Family"
8890
}
8991
],
92+
"descendants": ["GOOD", "failed", "retrying"],
9093
"childTasks": [
9194
{
9295
"name": "failed",
@@ -103,12 +106,14 @@
103106
"__typename": "Family",
104107
"id": "~user/one//$namespace|GOOD",
105108
"name": "GOOD",
109+
"firstParent": { "id": "~user/one//$namespace|root", "name": "root"},
106110
"parents": [
107111
{
108112
"name": "root",
109113
"_typename": "family"
110114
}
111115
],
116+
"descendants": ["SUCCEEDED"],
112117
"childTasks": [],
113118
"childFamilies": [
114119
{
@@ -121,12 +126,14 @@
121126
"__typename": "Family",
122127
"id": "~user/one//$namespace|SUCCEEDED",
123128
"name": "SUCCEEDED",
129+
"firstParent": { "id": "~user/one//$namespace|GOOD", "name": "GOOD"},
124130
"parents": [
125131
{
126132
"name": "GOOD",
127133
"_typename": "Family"
128134
}
129135
],
136+
"descendants": ["GOOD", "eventually_succeeded", "succeeded"],
130137
"childTasks": [
131138
{
132139
"name": "eventually_succeeded",

src/views/Graph.vue

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,14 @@ fragment JobData on Job {
200200
fragment FamilyData on Family {
201201
id
202202
name
203-
parents {
203+
firstParent {
204+
id
204205
name
205206
}
206207
childFamilies {
207208
name
208209
}
210+
descendants
209211
}
210212
211213
fragment AddedDelta on Added {
@@ -433,9 +435,7 @@ export default {
433435
if (this.familyArrayStore.length) {
434436
const ret = []
435437
for (const rootFamily of this.getTree()) {
436-
if (Object.keys(this.allParentLookUp).includes(rootFamily.name)) {
437-
ret.push(rootFamily)
438-
}
438+
ret.push(rootFamily)
439439
}
440440
return ret
441441
} else {
@@ -477,31 +477,16 @@ export default {
477477
allParentLookUp () {
478478
const lookup = {}
479479
for (const namespace of this.namespaces) {
480-
const indexSearch = Object.values(this.cylcTree.$index).find((node) => {
481-
return node.name === namespace.name
482-
})
483480
const array = []
484-
if (indexSearch.node.firstParent) {
485-
array.push(indexSearch.node.firstParent.name)
486-
}
487-
// Note this uses firtParent field to avoid issues with branching families
488-
let parent = indexSearch.node.firstParent
481+
let parent = namespace.node.firstParent
489482
while (parent) {
490-
const indexSearch = Object.values(this.cylcTree.$index).find((node) => {
491-
return node.name === parent.name
492-
})
493-
if (indexSearch.node.firstParent) {
494-
array.push(indexSearch.node.firstParent.name)
495-
parent = indexSearch.node.firstParent
496-
} else {
497-
parent = null
498-
}
499-
}
500-
if (array.length) {
501-
lookup[namespace.name] = array
483+
const childTokens = this.workflows[0].tokens.clone({ cycle: `$namespace|${parent.name}` })
484+
const childNode = this.cylcTree.$index[childTokens.id]
485+
array.push(childNode.name)
486+
parent = childNode.node.firstParent
502487
}
488+
lookup[namespace.name] = array
503489
}
504-
lookup.root = []
505490
return lookup
506491
},
507492
/**
@@ -701,9 +686,13 @@ export default {
701686
name: 'root',
702687
children: []
703688
}
704-
const tokens = this.workflows[0].tokens.clone({ cycle: '$namespace|root' })
705-
const node = this.cylcTree.$index[tokens.id]
706-
return this.getTreeHelper(root, node, counter).children
689+
if (this.workflows) {
690+
const tokens = this.workflows[0].tokens.clone({ cycle: '$namespace|root' })
691+
const node = this.cylcTree.$index[tokens.id]
692+
if (node) {
693+
return this.getTreeHelper(root, node, counter).children
694+
}
695+
}
707696
},
708697
/**
709698
* Get a nested object of families
@@ -713,24 +702,26 @@ export default {
713702
* @returns {Family} nested structure of families
714703
*/
715704
getTreeHelper (store, node, counter) {
716-
if (this.allParentLookUp[node.name]) {
717-
let tempItem
718-
const isParent = this.collapseFamily.includes(node.name)
719-
const isAncestor = this.allParentLookUp[node.name].some(element => {
720-
return this.collapseFamily.includes(element)
721-
})
722-
const disabled = isParent || isAncestor
723-
for (const childFamily of node.node.childFamilies) {
724-
const childTokens = this.workflows[0].tokens.clone({ cycle: `$namespace|${childFamily.name}` })
705+
let tempItem
706+
const isParent = this.collapseFamily.includes(node.name)
707+
const isAncestor = this.allParentLookUp[node.name].some(element => {
708+
return this.collapseFamily.includes(element)
709+
})
710+
const disabled = isParent || isAncestor
711+
for (const childFamily of node.node.descendants) {
712+
if (this.namespaces.map((obj) => obj.name).includes(childFamily)) {
713+
const childTokens = this.workflows[0].tokens.clone({ cycle: `$namespace|${childFamily}` })
725714
const childNode = this.cylcTree.$index[childTokens.id]
726-
tempItem = {
727-
id: counter.next(),
728-
name: childFamily.name,
729-
children: [],
730-
disabled
715+
if (childNode.node.firstParent.id === node.id) {
716+
tempItem = {
717+
id: counter.next(),
718+
name: childFamily,
719+
children: [],
720+
disabled
721+
}
722+
this.getTreeHelper(tempItem, childNode, counter)
723+
store.children.push(tempItem)
731724
}
732-
this.getTreeHelper(tempItem, childNode, counter)
733-
store.children.push(tempItem)
734725
}
735726
}
736727
return store

tests/unit/views/graph-utils.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ const nodeFailed =
6565
name: 'failed',
6666
firstParent: {
6767
id: 'user/one/run1//1/BAD'
68-
}
68+
},
69+
descendants: []
6970
},
7071
tokens: {
7172
cycle: '1'
@@ -78,9 +79,10 @@ const nodeNamespaceRoot =
7879
name: 'root',
7980
node: {
8081
name: 'root',
81-
parents: [],
82+
firstParent: null,
8283
childFamilies: [{ name: 'GOOD' }, { name: 'BAD' }],
83-
childTasks: [{ name: 'checkpoint' }, { name: 'sleepy' }, { name: 'waiting' }]
84+
childTasks: [{ name: 'checkpoint' }, { name: 'sleepy' }, { name: 'waiting' }],
85+
descendants: ['GOOD', 'SUCCEEDED', 'BAD', 'checkpoint', 'sleepy', 'waiting', 'retrying', 'failed', 'succeeded', 'eventually_succeeded']
8486
},
8587
tokens: { cycle: undefined }
8688
}
@@ -91,9 +93,10 @@ const nodeNamespaceBad =
9193
name: 'BAD',
9294
node: {
9395
name: 'root',
94-
parents: [{ name: 'root' }],
96+
firstParent: {id: 'user/one/run1//$namespace|root', name: 'root'},
9597
childFamilies: [],
96-
childTasks: [{ name: 'retrying' }, { name: 'failed' }]
98+
childTasks: [{ name: 'retrying' }, { name: 'failed' }],
99+
descendants: ['retrying', 'failed']
97100
},
98101
tokens: { cycle: undefined }
99102
}
@@ -104,9 +107,10 @@ const nodeNamespaceGood =
104107
name: 'GOOD',
105108
node: {
106109
name: 'GOOD',
107-
parents: [{ name: 'root' }],
110+
firstParent: {id: 'user/one/run1//$namespace|root', name: 'root'},
108111
childFamilies: [{ name: 'SUCCEEDED' }],
109-
childTasks: [{ name: 'retrying' }, { name: 'failed' }]
112+
childTasks: [{ name: 'succeeded' }, { name: 'eventually_succeeded' }],
113+
descendants: ['SUCCEEDED', 'succeeded', 'eventually_succeeded']
110114
},
111115
tokens: { cycle: undefined }
112116
}
@@ -117,9 +121,10 @@ const nodeNamespaceSucceeded =
117121
name: 'SUCCEEDED',
118122
node: {
119123
name: 'GOOD',
120-
parents: [{ name: 'GOOD' }],
124+
firstParent: {id: 'user/one/run1//$namespace|GOOD', name: 'GOOD'},
121125
childFamilies: [],
122-
childTasks: [{ name: 'succeeded' }, { name: 'eventually_succeeded' }]
126+
childTasks: [{ name: 'succeeded' }, { name: 'eventually_succeeded' }],
127+
descendants: ['succeeded', 'eventually_succeeded'],
123128
},
124129
tokens: { cycle: undefined }
125130
}
@@ -130,16 +135,18 @@ const workflows = [
130135
node: {
131136
firstParent: {
132137
id: ''
133-
}
138+
},
139+
descendants: []
134140
},
135141
children: [
136142
{
137143
id: '~user/one//1',
138144
tokens: { cycle: 1 },
139145
node: {
140146
firstParent: {
141-
id: ''
142-
}
147+
id: '~user/one'
148+
},
149+
descendants: []
143150
},
144151
children: [
145152
{

0 commit comments

Comments
 (0)