v2routers: Use hoodid to identify V1 hoods

All V1 hoods are assigned to IDs 10xxx in the hoods table.
Since no new hoods are added, they are contained in this range.

In addition, the hoods table is forever, so deleted V1 hoods
stay there. This makes the hoodid a perfect WHERE criterion for
the v2routers page, so it does not have to be updated for every
deleted hood.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-11-23 21:26:42 +01:00
parent 1f1d04abc8
commit 2ee6da55e9
1 changed files with 1 additions and 2 deletions

View File

@ -88,8 +88,7 @@ def v2_routers():
SELECT time, CAST(SUM(clients) AS SIGNED) clients, CAST(SUM(online) AS SIGNED) online, CAST(SUM(offline) AS SIGNED) offline, CAST(SUM(unknown) AS SIGNED) unknown, CAST(SUM(orphaned) AS SIGNED) orphaned, CAST(SUM(rx) AS SIGNED) rx, CAST(SUM(tx) AS SIGNED) tx
FROM stats_hood
INNER JOIN hoods ON hoods.id = stats_hood.hood
LEFT JOIN hoodsv1 ON hoodsv1.name = hoods.name
WHERE time > 1531612800 AND ( hoodsv1.name IS NOT NULL OR hoods.name IN ('ArnsteinV1','MuenchbergV1','MarktredwitzV1','BayreuthV1','AnsbachV1','FichtelbergV1','BambergV1','ForchheimV1','ErlangenV1','ErlangenWestV1','EbernV1','CoburgV1','HassbergeV1','LaufV1','RehauV1','AschaffenburgV1','WuerzburgV1','AdelsdorfV1','EbermannstadtV1','NuernbergV1','HassbergeSuedV1','FuerthV1','SchweinfurtV1','BGLV1') )
WHERE time > 1531612800 AND ( hoods.id > 9999 AND hoods.id < 11000 )
GROUP BY time
""")
mysql.close()