Remove hoodsv1 table and corresponding interface with KeyXchangeV1
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
98af250294
commit
71802221a0
|
@ -35,28 +35,6 @@ mysql.execute("""
|
|||
VALUES (%s, %s)
|
||||
""",(10100,Legacy,))
|
||||
|
||||
mysql.execute("""
|
||||
CREATE TABLE `hoodsv1` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`name` varchar(30) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`net` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`lat` double DEFAULT NULL,
|
||||
`lng` double DEFAULT NULL,
|
||||
`cos_lat` double DEFAULT NULL,
|
||||
`sin_lat` double DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
|
||||
""")
|
||||
|
||||
mysql.execute("""
|
||||
ALTER TABLE `hoodsv1`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `name` (`name`),
|
||||
ADD KEY `lat` (`lat`),
|
||||
ADD KEY `lng` (`lng`),
|
||||
ADD KEY `cos_lat` (`cos_lat`),
|
||||
ADD KEY `sin_lat` (`sin_lat`)
|
||||
""")
|
||||
|
||||
mysql.execute("""
|
||||
CREATE TABLE `hoodsv2` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
|
|
|
@ -67,46 +67,3 @@ def update_hoods_poly(mysql):
|
|||
|
||||
except urllib.error.HTTPError as e:
|
||||
return
|
||||
|
||||
def update_hoods_v1(mysql):
|
||||
try:
|
||||
with urllib.request.urlopen("http://keyserver.freifunk-franken.de/fff/hoods.php") as url:
|
||||
hoodskx = json.loads(url.read().decode())
|
||||
|
||||
kx_keys = []
|
||||
kx_data = []
|
||||
for kx in hoodskx:
|
||||
if kx["id"]==0:
|
||||
continue # Skip Trainstation/NoCoordinates
|
||||
kx_keys.append(kx["id"])
|
||||
if kx.get("lat",None):
|
||||
cos_lat = math.cos(math.radians(kx["lat"]))
|
||||
sin_lat = math.sin(math.radians(kx["lat"]))
|
||||
else:
|
||||
cos_lat = None
|
||||
sin_lat = None
|
||||
kx["name"] = kx["name"][0].upper() + kx["name"][1:] + "V1"
|
||||
kx_data.append((kx["id"],kx["name"],kx["net"],kx.get("lat",None),kx.get("lon",None),cos_lat,sin_lat,))
|
||||
|
||||
# Delete entries in DB where hood is missing in KeyXchange
|
||||
db_keys = mysql.fetchall("SELECT id FROM hoodsv1",(),"id")
|
||||
for n in db_keys:
|
||||
if n in kx_keys or n==0:
|
||||
continue
|
||||
mysql.execute("DELETE FROM hoodsv1 WHERE id = %s",(n,))
|
||||
|
||||
# Create/update entries from KeyXchange to DB
|
||||
mysql.executemany("""
|
||||
INSERT INTO hoodsv1 (id, name, net, lat, lng, cos_lat, sin_lat)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
name=VALUES(name),
|
||||
net=VALUES(net),
|
||||
lat=VALUES(lat),
|
||||
lng=VALUES(lng),
|
||||
cos_lat=VALUES(cos_lat),
|
||||
sin_lat=VALUES(sin_lat)
|
||||
""",kx_data)
|
||||
|
||||
except urllib.error.HTTPError as e:
|
||||
return
|
||||
|
|
|
@ -136,7 +136,7 @@ def defrag_table(mysql,table,sleep):
|
|||
print("--- Defragmented table %s: %.3f seconds ---" % (table,end_time - start_time))
|
||||
|
||||
def defrag_all(mysql,doall=False):
|
||||
alltables = ('gw','gw_admin','gw_netif','hoods','hoodsv1','hoodsv2','netifs','router','router_events','router_gw','router_ipv6','router_neighbor','router_netif','users')
|
||||
alltables = ('gw','gw_admin','gw_netif','hoods','hoodsv2','netifs','router','router_events','router_gw','router_ipv6','router_neighbor','router_netif','users')
|
||||
stattables = ('router_stats','router_stats_gw','router_stats_neighbor','router_stats_netif','stats_global','stats_gw','stats_hood')
|
||||
|
||||
for t in alltables:
|
||||
|
|
|
@ -10,7 +10,7 @@ from ffmap.routertools import *
|
|||
from ffmap.maptools import *
|
||||
from ffmap.mysqltools import FreifunkMySQL
|
||||
from ffmap.stattools import record_global_stats, record_hood_stats, record_gw_stats
|
||||
from ffmap.hoodtools import update_hoods_v2, update_hoods_v1
|
||||
from ffmap.hoodtools import update_hoods_v2
|
||||
|
||||
import time
|
||||
start_time = time.time()
|
||||
|
@ -21,7 +21,6 @@ detect_orphaned_routers(mysql)
|
|||
delete_orphaned_routers(mysql)
|
||||
#delete_old_stats(mysql) # Only execute once daily, takes 2 minutes
|
||||
update_hoods_v2(mysql)
|
||||
update_hoods_v1(mysql)
|
||||
record_global_stats(mysql)
|
||||
record_hood_stats(mysql)
|
||||
record_gw_stats(mysql)
|
||||
|
|
Loading…
Reference in New Issue