[BUGFIX] Filter links by node + perfomance using dict/map

This commit is contained in:
Geno 2017-10-29 20:14:09 +01:00 committed by Xaver Maierhofer
parent fb857717fd
commit d6b84eba22
3 changed files with 6 additions and 33 deletions

View File

@ -12,26 +12,8 @@ define(function () {
}
}
var filteredIds = new Set();
n.graph = {};
n.graph.nodes = data.graph.nodes.filter(function (d) {
var r;
if (d.node) {
r = filter(d.node);
} else {
r = filter({});
}
if (r) {
filteredIds.add(d.id);
}
return r;
});
n.graph.links = data.graph.links.filter(function (d) {
return filteredIds.has(d.source.id) && filteredIds.has(d.target.id);
n.links = data.links.filter(function (d) {
return filter(d.source) && filter(d.target);
});
return n;

View File

@ -229,9 +229,9 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
}
function renderNeighbourRow(n) {
var icons = [];
var icons = '';
if (helper.hasLocation(n.node)) {
icons.push(V.h('span', { props: { className: 'ion-location' } }));
icons = V.h('span', { props: { className: 'ion-location' } });
}
var td1 = V.h('td', icons);

View File

@ -32,13 +32,8 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
});
links.forEach(function (d) {
d.source = nodes.find(function (a) {
return a.node_id === d.source;
});
d.target = nodes.find(function (a) {
return a.node_id === d.target;
});
d.source = nodeDict[d.source];
d.target = nodeDict[d.target];
d.id = [d.source.node_id, d.target.node_id].join('-');
d.source.neighbours.push({ node: d.target, link: d });
@ -68,10 +63,6 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
lost: lostnodes
},
links: links,
graph: {
links: [],
nodes: []
},
nodeDict: nodeDict
};
}