From 003fcbcebe5f9aa304868acd35bd291e333aa6ae Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 15 Nov 2017 11:39:24 +0100 Subject: [PATCH] routertools/stattools: Implement default hood as str "Default" If the default is NULL (as previously), we have ugly problems with indexing and queries. To circumvent this, the hood is set to "Default" right at the beginning. For old data, we add an if to the hood stats calculation. Signed-off-by: Adrian Schmutzler --- ffmap/routertools.py | 4 ++-- ffmap/stattools.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ffmap/routertools.py b/ffmap/routertools.py index 97688ad..77b029d 100644 --- a/ffmap/routertools.py +++ b/ffmap/routertools.py @@ -91,8 +91,8 @@ def import_nodewatcher_xml(mysql, mac, xml): distance ASC LIMIT 1 """,(lat,lng,lat,),"name") - else: - router_update["hood"] = None + if not router_update["hood"]: + router_update["hood"] = "Default" if router_id: # statistics diff --git a/ffmap/stattools.py b/ffmap/stattools.py index a7f9e8b..21ab252 100644 --- a/ffmap/stattools.py +++ b/ffmap/stattools.py @@ -150,6 +150,9 @@ def record_hood_stats(mysql): clients = total_clients_hood(mysql) for hood in clients.keys(): + if not hood: + hood = "Default" + old = mysql.findone("SELECT time FROM stats_hood WHERE time = %s AND hood = %s LIMIT 1",(time,hood,)) if old: