routertools: Don't delete old stats of offline routers
With this patch, router stats are only deleted if the router is online or missing in the router table. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
42c78f1079
commit
846f66281e
|
@ -262,18 +262,21 @@ def delete_old_stats(mysql):
|
|||
threshold=mysql.formatdt(utcnow() - datetime.timedelta(days=CONFIG["router_stat_days"]))
|
||||
|
||||
mysql.execute("""
|
||||
DELETE FROM router_stats
|
||||
WHERE time < %s
|
||||
DELETE s FROM router_stats AS s
|
||||
LEFT JOIN router AS r ON s.router = r.id
|
||||
WHERE s.time < %s AND (r.status = 'online' OR r.status IS NULL)
|
||||
""",(threshold,))
|
||||
|
||||
mysql.execute("""
|
||||
DELETE FROM router_stats_neighbor
|
||||
WHERE time < %s
|
||||
DELETE s FROM router_stats_neighbor AS s
|
||||
LEFT JOIN router AS r ON s.router = r.id
|
||||
WHERE s.time < %s AND (r.status = 'online' OR r.status IS NULL)
|
||||
""",(threshold,))
|
||||
|
||||
mysql.execute("""
|
||||
DELETE FROM router_stats_netif
|
||||
WHERE time < %s
|
||||
DELETE s FROM router_stats_netif AS s
|
||||
LEFT JOIN router AS r ON s.router = r.id
|
||||
WHERE s.time < %s AND (r.status = 'online' OR r.status IS NULL)
|
||||
""",(threshold,))
|
||||
|
||||
events = mysql.fetchall("""
|
||||
|
|
Loading…
Reference in New Issue