routertools: Fix query sequence when setting rx/tx to zero

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-01-18 13:02:10 +01:00
parent acf74276ce
commit 42ddf02265
1 changed files with 6 additions and 5 deletions

View File

@ -332,17 +332,18 @@ def detect_offline_routers(mysql):
VALUES (%s, %s, 'offline', '')
""",rdata)
mysql.execute("""
UPDATE router
SET status = 'offline', clients = 0
WHERE last_contact < %s AND status <> 'offline' AND status <> 'orphaned'
""",(threshold,))
mysql.execute("""
UPDATE router_netif AS n
INNER JOIN router AS r ON r.id = n.router
SET n.rx = 0, n.tx = 0
WHERE r.last_contact < %s AND r.status <> 'offline' AND r.status <> 'orphaned'
""",(threshold,))
# Online to Offline has to be updated after other queries!
mysql.execute("""
UPDATE router
SET status = 'offline', clients = 0
WHERE last_contact < %s AND status <> 'offline' AND status <> 'orphaned'
""",(threshold,))
mysql.commit()
def detect_orphaned_routers(mysql):