forked from DebaucheryLibrarian/traxxx
Including all children of included networks, separated included children into dedicated property.
This commit is contained in:
@@ -39,14 +39,11 @@ function curateEntity(entity, includeParameters = false) {
|
||||
}, includeParameters));
|
||||
}
|
||||
|
||||
if (entity.siblings) {
|
||||
curatedEntity.parent = {
|
||||
...curatedEntity.parent,
|
||||
children: entity.siblings.map(sibling => curateEntity({
|
||||
...sibling,
|
||||
parent: curatedEntity.parent,
|
||||
}, includeParameters)),
|
||||
};
|
||||
if (entity.included_children) {
|
||||
curatedEntity.includedChildren = entity.included_children.map(child => curateEntity({
|
||||
...child,
|
||||
parent: curatedEntity.id ? curatedEntity : null,
|
||||
}, includeParameters));
|
||||
}
|
||||
|
||||
if (entity.tags) {
|
||||
@@ -119,7 +116,11 @@ async function fetchIncludedEntities() {
|
||||
)
|
||||
/* select recursive channels as children of networks */
|
||||
SELECT
|
||||
parents.*, json_agg(included_entities ORDER BY included_entities.id) as children
|
||||
parents.*,
|
||||
json_agg(included_entities ORDER BY included_entities.id) included_children,
|
||||
(SELECT json_agg(children)
|
||||
FROM entities AS children
|
||||
WHERE children.parent_id = parents.id) children
|
||||
FROM
|
||||
included_entities
|
||||
LEFT JOIN
|
||||
@@ -130,9 +131,6 @@ async function fetchIncludedEntities() {
|
||||
parents.id;
|
||||
`, include);
|
||||
|
||||
// console.log(rawNetworks.rows[0]);
|
||||
// console.log(rawNetworks.toString());
|
||||
|
||||
const curatedNetworks = rawNetworks.rows.map(entity => curateEntity(entity, true));
|
||||
|
||||
return curatedNetworks;
|
||||
|
||||
Reference in New Issue
Block a user