routertools/alfred: Minimize time without router_netif data

Rearrange queries to have a minimum time where netifs for router
are not present.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-12-05 08:52:25 +01:00
parent a994ec114a
commit 9e6e3c8dbf
1 changed files with 5 additions and 3 deletions

View File

@ -109,11 +109,10 @@ def import_nodewatcher_xml(mysql, mac, xml):
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],
ru["status_text"],ru["contact"],ru["lng"],ru["lat"],ru["visible_neighbours"],reset,router_id,))
mysql.execute("DELETE FROM router_netif WHERE router = %s",(router_id,))
mysql.execute("DELETE FROM router_ipv6 WHERE router = %s",(router_id,))
mysql.execute("DELETE FROM router_neighbor WHERE router = %s",(router_id,))
mysql.execute("DELETE FROM router_ipv6 WHERE router = %s",(router_id,))
mysql.execute("DELETE FROM router_netif WHERE router = %s",(router_id,))
new_router_stats(mysql, router_id, uptime, router_update)
else:
# insert new router
created = mysql.utcnow()
@ -153,6 +152,9 @@ def import_nodewatcher_xml(mysql, mac, xml):
mysql.executemany("INSERT INTO router_neighbor (router, mac, quality, net_if, type) VALUES (%s, %s, %s, %s, %s)",nbdata)
if router_id:
new_router_stats(mysql, router_id, uptime, router_update)
status = router_update["status"]
except ValueError as e:
import traceback