Skip to content

Instantly share code, notes, and snippets.

@YajanaRao
Created November 7, 2021 17:17
Show Gist options
  • Save YajanaRao/a6693005fb9ab9d07054bdd4be3387c7 to your computer and use it in GitHub Desktop.
Save YajanaRao/a6693005fb9ab9d07054bdd4be3387c7 to your computer and use it in GitHub Desktop.
Dependency graph data
const response = {
"response": {
"534": {
"in": [],
"out": []
},
"535": {
"in": [],
"out": []
},
"1363": {
"in": [],
"out": []
},
"1364": {
"in": [],
"out": []
},
"1365": {
"in": [],
"out": []
},
"1366": {
"in": [],
"out": []
},
"1370": {
"in": [],
"out": []
},
"1371": {
"in": [],
"out": []
},
"1834": {
"in": [],
"out": []
},
"1835": {
"in": [],
"out": []
},
"1841": {
"in": [],
"out": []
},
"1842": {
"in": [],
"out": []
},
"2459": {
"in": [],
"out": []
},
"2468": {
"in": [],
"out": []
},
"2469": {
"in": [],
"out": []
},
"2470": {
"in": [],
"out": []
},
"2471": {
"in": [],
"out": [
{
"resource_id": 3533,
"workspace_name": null,
"workspace_id": null,
"datasource_id": 1312,
"datasource_name": "Company Properties",
"props": {
"object_id": 633,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1061
}
}
}
]
},
"2474": {
"in": [],
"out": []
},
"2475": {
"in": [],
"out": []
},
"2476": {
"in": [],
"out": []
},
"2477": {
"in": [],
"out": [
{
"resource_id": 3511,
"workspace_name": null,
"workspace_id": null,
"datasource_id": 1303,
"datasource_name": "Engine",
"props": {
"object_id": 631,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1064
}
}
}
]
},
"2484": {
"in": [],
"out": []
},
"2485": {
"in": [],
"out": []
},
"2486": {
"in": [],
"out": []
},
"2487": {
"in": [],
"out": []
},
"2993": {
"in": [],
"out": []
},
"2996": {
"in": [],
"out": []
},
"2997": {
"in": [],
"out": []
},
"2998": {
"in": [],
"out": []
},
"2999": {
"in": [],
"out": []
},
"3511": {
"in": [
{
"resource_id": 2477,
"workspace_name": "View 1",
"workspace_id": 1064,
"datasource_id": 925,
"datasource_name": "_office_main_excel_office_main_2_view_1",
"props": {
"object_id": 631,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1064
}
}
}
],
"out": []
},
"3512": {
"in": [],
"out": []
},
"3513": {
"in": [],
"out": []
},
"3514": {
"in": [],
"out": []
},
"3515": {
"in": [],
"out": []
},
"3516": {
"in": [],
"out": []
},
"3517": {
"in": [],
"out": []
},
"3518": {
"in": [],
"out": []
},
"3519": {
"in": [],
"out": []
},
"3520": {
"in": [],
"out": []
},
"3521": {
"in": [],
"out": []
},
"3522": {
"in": [],
"out": []
},
"3533": {
"in": [
{
"resource_id": 2471,
"workspace_name": "View 1",
"workspace_id": 1061,
"datasource_id": 922,
"datasource_name": "CompanyProperties",
"props": {
"object_id": 633,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1061
}
}
}
],
"out": []
},
"3534": {
"in": [],
"out": [
{
"resource_id": 3647,
"workspace_name": null,
"workspace_id": null,
"datasource_id": 1351,
"datasource_name": "Result Dataset",
"props": {
"object_id": 651,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1518
}
}
}
]
},
"3647": {
"in": [
{
"resource_id": 3534,
"workspace_name": "View 1",
"workspace_id": 1518,
"datasource_id": 1312,
"datasource_name": "Company Properties",
"props": {
"object_id": 651,
"object_type": "ACTION",
"object_name": "BRANCH_OUT",
"object_props": {
"source_workspace_id": 1518
}
}
}
],
"out": []
},
"3648": {
"in": [],
"out": []
}
},
"STATUS": "SUCCESS"
}
const data = response.response;
function getData(){
let dataset = getResource('2471');
while(dataset?.out){
console.log("while");
dataset = getResource(dataset.out[0].resource_id)
}
}
function getResource(resource_id){
const dataset = data[resource_id];
console.log(dataset, resource_id);
return dataset;
}
getData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment