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:
Adrian Schmutzler 2019-10-11 19:37:48 +02:00
parent 6a401f8246
commit 6805baa352
1 changed files with 3 additions and 2 deletions

View File

@ -434,7 +434,7 @@ def delete_orphaned_routers(mysql):
def delete_unlinked_routers(mysql):
# 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:
start_time = time.time()
@ -443,6 +443,7 @@ def delete_unlinked_routers(mysql):
LEFT JOIN router AS r ON r.id = d.router
WHERE r.id IS NULL
""".format(t))
mysql.commit()
#mysql.execute("""
# DELETE FROM {}
# WHERE {}.router NOT IN (
@ -450,7 +451,7 @@ def delete_unlinked_routers(mysql):
# )
#""".format(t,t))
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):
minustime=0