From 63ac6ffc06cfc0498e6fa438e569916345349137 Mon Sep 17 00:00:00 2001 From: Vanhala Antti Date: Thu, 5 Jun 2014 00:27:06 +0300 Subject: [PATCH] Don't lose edges for a week --- web/database.py | 6 ++++-- web/updateGraph.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web/database.py b/web/database.py index 5c9111e..c058a8a 100644 --- a/web/database.py +++ b/web/database.py @@ -70,8 +70,10 @@ class NodeDB: edges = [] for e in db_edges: - edges.append(Edge(nodes[e['a']], nodes[e['b']])) - + try: + edges.append(Edge(nodes[e['a']], nodes[e['b']])) + except KeyError: + pass return edges def get_graph(self, time_limit): diff --git a/web/updateGraph.py b/web/updateGraph.py index 50daaaf..97deeeb 100755 --- a/web/updateGraph.py +++ b/web/updateGraph.py @@ -20,7 +20,9 @@ def load_graph_from_db(time_limit): config.from_pyfile('web_config.cfg') with NodeDB(config) as db: - return db.get_graph(time_limit) + nodes = db.get_nodes(time_limit) + edges = db.get_edges(nodes, 60*60*24*7) + return (nodes, edges) if __name__ == '__main__':