statistics.html: Show number of gateways in hood table
The number counts all GWs with 2 or more online routers. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
0ce3fa5c2f
commit
d8e9add933
|
@ -159,6 +159,26 @@ def hoods_sum(mysql,selectgw=None):
|
|||
result[rs["hood"]] = {"routers": rs["count"], "clients": rs["clients"]}
|
||||
return result
|
||||
|
||||
def hoods_gws(mysql):
|
||||
data = mysql.fetchall("""
|
||||
SELECT hood, COUNT(sub.mac) AS count
|
||||
FROM (
|
||||
SELECT hood, router_gw.mac, COUNT(router.id) AS routers
|
||||
FROM router
|
||||
INNER JOIN router_gw ON router.id = router_gw.router
|
||||
WHERE router.status = 'online'
|
||||
GROUP BY hood, router_gw.mac
|
||||
) AS sub
|
||||
WHERE routers > 1
|
||||
GROUP BY hood
|
||||
""")
|
||||
result = {}
|
||||
for rs in data:
|
||||
if not rs["hood"]:
|
||||
rs["hood"] = "Default"
|
||||
result[rs["hood"]] = rs["count"]
|
||||
return result
|
||||
|
||||
def gws(mysql,selecthood=None):
|
||||
if selecthood:
|
||||
where = " AND hood=%s"
|
||||
|
|
|
@ -393,6 +393,7 @@ def helper_statistics(mysql,stats,selecthood,selectgw):
|
|||
router_models = stattools.router_models(mysql,selecthood,selectgw)
|
||||
router_firmwares = stattools.router_firmwares(mysql,selecthood,selectgw)
|
||||
hoods_sum = stattools.hoods_sum(mysql,selectgw)
|
||||
hoods_gws = stattools.hoods_gws(mysql)
|
||||
gws = stattools.gws(mysql,selecthood)
|
||||
gws_sum = stattools.gws_sum(mysql,selecthood)
|
||||
gws_info = stattools.gws_info(mysql,selecthood)
|
||||
|
@ -409,6 +410,7 @@ def helper_statistics(mysql,stats,selecthood,selectgw):
|
|||
router_firmwares = router_firmwares,
|
||||
hoods = hoods,
|
||||
hoods_sum = hoods_sum,
|
||||
hoods_gws = hoods_gws,
|
||||
newest_routers = newest_routers,
|
||||
gws = gws,
|
||||
gws_sum = gws_sum,
|
||||
|
|
|
@ -54,16 +54,18 @@
|
|||
<table class="table table-condensed table-hoods">
|
||||
<tr>
|
||||
<th class="firstrow">Hood</th>
|
||||
<th class="success" title="Online Routers">Online</th>
|
||||
<th class="danger" title="Offline Routers">Offline</th>
|
||||
<th class="warning" title="Unknown Routers">Unknown</th>
|
||||
<th class="active" title="Total Routers">Total</th>
|
||||
<th class="stats" title="Gateways">GW</th>
|
||||
<th class="success" title="Online Routers">On</th>
|
||||
<th class="danger" title="Offline Routers">Off</th>
|
||||
<th class="warning" title="Unknown Routers">Unkn.</th>
|
||||
<th class="active" title="Total Routers">Sum</th>
|
||||
<th class="info">Clients</th>
|
||||
<th class="stats">Stats</th>
|
||||
</tr>
|
||||
{%- for hood, value in hoods|dictsort %}
|
||||
<tr>
|
||||
<td class="firstrow"><a href="{{ url_for('router_list', q='hood:^%s$' % hood.replace(' ','_')) }}">{{ hood }}</a></td>
|
||||
<td class="stats">{{ hoods_gws[hood] or "-" }}</td>
|
||||
<td class="success">{{ value["online"] or 0 }}</td>
|
||||
<td class="danger">{{ value["offline"] or 0 }}{%- if value["orphaned"] %} ({{ value["orphaned"] or 0 }}){%- endif %}</td>
|
||||
<td class="warning">{{ value["unknown"] or 0 }}</td>
|
||||
|
@ -74,6 +76,7 @@
|
|||
{%- endfor %}
|
||||
<tr>
|
||||
<th class="firstrow">Sum</th>
|
||||
<td class="stats"> </td>
|
||||
<td class="success">{{ router_status.online or 0 }}</td>
|
||||
<td class="danger">{{ router_status.offline or 0 }}</td>
|
||||
<td class="warning">{{ router_status.unknown or 0 }}</td>
|
||||
|
|
Loading…
Reference in New Issue