From 7d2488bcc51994ff4f5f965f67608cd42db2972d Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 13 Aug 2018 16:14:10 +0200 Subject: [PATCH] v2routers: Added page for V1/V2 comparison Selection of deleted hoods for V1 is a dirty walkaround and needs to be adjusted for every new deleted hood. Since this is an undocumented page, this is okay ... Signed-off-by: Adrian Schmutzler --- ffmap/web/application.py | 32 +++++++++ ffmap/web/templates/v2routers.html | 108 +++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 ffmap/web/templates/v2routers.html diff --git a/ffmap/web/application.py b/ffmap/web/application.py index 0897923..c9c82e5 100755 --- a/ffmap/web/application.py +++ b/ffmap/web/application.py @@ -71,6 +71,38 @@ def router_list(): return render_template("router_list.html", query_str=query_str, routers=routers, numrouters=len(routers)) +# test +@app.route('/v2routers') +def v2_routers(): + try: + mysql = FreifunkMySQL() + statsv2 = mysql.fetchall(""" + 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 + INNER JOIN hoodsv2 ON hoodsv2.name = hoods.name + WHERE time > 1531612800 + GROUP BY time + """) + statsv1 = mysql.fetchall(""" + 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') ) + GROUP BY time + """) + mysql.close() + statsv2 = mysql.utcawaretupleint(statsv2,"time") + statsv1 = mysql.utcawaretupleint(statsv1,"time") + + return render_template("v2routers.html",statsv2 = statsv2,statsv1 = statsv1) + except Exception as e: + writelog(CONFIG["debug_dir"] + "/fail_v2.txt", str(e)) + import traceback + writefulllog("Warning: Failed to display v2 page: %s\n__%s" % (e, traceback.format_exc().replace("\n", "\n__"))) + + # router by mac (short link version) @app.route('/mac/', methods=['GET']) def router_mac(mac): diff --git a/ffmap/web/templates/v2routers.html b/ffmap/web/templates/v2routers.html new file mode 100644 index 0000000..ead23eb --- /dev/null +++ b/ffmap/web/templates/v2routers.html @@ -0,0 +1,108 @@ +{% extends "bootstrap.html" %} +{% block title %}{{super()}} :: Statistics{% endblock %} +{% block head %}{{super()}} + + + + + + + + + + + + + + + +{% endblock %} + +{% block content %} +
+
+
+
Routers V1: {{ statsv1[-1]["online"] }} on, {{ statsv1[-1]["offline"] }} off, {{ statsv1[-1]["unknown"] }} unknown, {{ statsv1[-1]["orphaned"] }} orphaned; {{ statsv1[-1]["online"]+statsv1[-1]["offline"]+statsv1[-1]["unknown"]+statsv1[-1]["orphaned"] }} total
+
+
+
+
+
+
Clients V1: {{ statsv1[-1]["clients"] }}
+
+
+
+
+
+
Traffic V1
+
+
+
+
+
+
+
+
Routers V2: {{ statsv2[-1]["online"] }} on, {{ statsv2[-1]["offline"] }} off, {{ statsv2[-1]["unknown"] }} unknown, {{ statsv2[-1]["orphaned"] }} orphaned; {{ statsv2[-1]["online"]+statsv2[-1]["offline"]+statsv2[-1]["unknown"]+statsv2[-1]["orphaned"] }} total
+
+
+
+
+
+
Clients V2: {{ statsv2[-1]["clients"] }}
+
+
+
+
+
+
Traffic V2
+
+
+
+
+
+
+ +{% endblock %} +