scripts/deleteunlinked.py: Add old-stats tables and sleep
This adds the new old-stats tables to the script looking for lost router-dependent entries. While at it, add a short sleep between queries. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
6a401f8246
commit
6805baa352
|
@ -434,7 +434,7 @@ def delete_orphaned_routers(mysql):
|
||||||
def delete_unlinked_routers(mysql):
|
def delete_unlinked_routers(mysql):
|
||||||
# Delete entries in router_* tables without corresponding router in master table
|
# Delete entries in router_* tables without corresponding router in master table
|
||||||
|
|
||||||
tables = ["router_events","router_gw","router_ipv6","router_neighbor","router_netif","router_stats","router_stats_gw","router_stats_neighbor","router_stats_netif"]
|
tables = ["router_events","router_gw","router_ipv6","router_neighbor","router_netif","router_stats","router_stats_gw","router_stats_neighbor","router_stats_netif","router_stats_old","router_stats_old_gw","router_stats_old_neighbor","router_stats_old_netif"]
|
||||||
|
|
||||||
for t in tables:
|
for t in tables:
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
@ -443,6 +443,7 @@ def delete_unlinked_routers(mysql):
|
||||||
LEFT JOIN router AS r ON r.id = d.router
|
LEFT JOIN router AS r ON r.id = d.router
|
||||||
WHERE r.id IS NULL
|
WHERE r.id IS NULL
|
||||||
""".format(t))
|
""".format(t))
|
||||||
|
mysql.commit()
|
||||||
#mysql.execute("""
|
#mysql.execute("""
|
||||||
# DELETE FROM {}
|
# DELETE FROM {}
|
||||||
# WHERE {}.router NOT IN (
|
# WHERE {}.router NOT IN (
|
||||||
|
@ -450,7 +451,7 @@ def delete_unlinked_routers(mysql):
|
||||||
# )
|
# )
|
||||||
#""".format(t,t))
|
#""".format(t,t))
|
||||||
print("--- Deleted %i rows from %s: %.3f seconds ---" % (mysql.cursor().rowcount,t,time.time() - start_time))
|
print("--- Deleted %i rows from %s: %.3f seconds ---" % (mysql.cursor().rowcount,t,time.time() - start_time))
|
||||||
mysql.commit()
|
time.sleep(1)
|
||||||
|
|
||||||
def delete_stats_helper(mysql,label,query,tuple):
|
def delete_stats_helper(mysql,label,query,tuple):
|
||||||
minustime=0
|
minustime=0
|
||||||
|
|
Loading…
Reference in New Issue