ensure unique ids for links and nodes
This commit is contained in:
parent
b5c8f9b6bc
commit
c7b33a4839
|
@ -7,13 +7,16 @@ class D3MapBuilder:
|
|||
def build(self):
|
||||
output = dict()
|
||||
|
||||
nodes = self._db.get_nodes()
|
||||
|
||||
output['nodes'] = [{'group': x.group, 'name': x.name, 'id': x.id,
|
||||
'macs': ', '.join(x.macs)
|
||||
} for x in self._db.get_nodes() if x.online]
|
||||
} for x in nodes if x.online]
|
||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||
'distance': x.distance,
|
||||
'strength': x.strength,
|
||||
'quality': x.quality
|
||||
'quality': x.quality,
|
||||
'id': "-".join(nodes[i].id for i in x.pair)
|
||||
} for x in self._db.get_links()]
|
||||
|
||||
return json.dumps(output)
|
||||
|
|
Loading…
Reference in a new issue