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 <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-11-15 11:39:24 +01:00
parent 48cb9f0033
commit 003fcbcebe
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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: