}
@app.get(fba.config["base_url"] + "/top")
-def top(blocked: int = None, blockers: int = None):
- if blocked == None and blockers == None:
+def top(blocked: int = None, blockers: int = None, reference: int = None):
+ if blocked == None and blockers == None and reference == None:
raise HTTPException(status_code=400, detail="No filter specified")
elif blocked != None:
if blocked > 500:
if blockers > 500:
raise HTTPException(status_code=400, detail="Too many results")
fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY COUNT(blocker) DESC LIMIT ?", [blockers])
+ elif reference != None:
+ if reference > 500:
+ raise HTTPException(status_code=400, detail="Too many results")
+ fba.c.execute("SELECT origin, COUNT(domain) FROM instances ORDER BY COUNT(domain) DESC LIMIT ?", [reference])
+
scores = fba.c.fetchall()
scoreboard = []
return result
@app.get(fba.config["base_url"] + "/scoreboard")
-def index(request: Request, blockers: int = None, blocked: int = None):
- if blockers == None and blocked == None:
+def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None):
+ scores = None
+
+ if blockers == None and blocked == None and reference == None:
raise HTTPException(status_code=400, detail="No filter specified")
elif blockers != None:
scores = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blockers={blockers}")
elif blocked != None:
scores = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blocked={blocked}")
+ elif reference != None:
+ scores = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?reference={reference}")
if scores != None:
if not scores.ok:
"scoreboard": True,
"blockers": blockers,
"blocked": blocked,
+ "reference": reference,
"scores": scores
})
<h1>Top {{blockers}} defederating instances</h1>
{% elif blocked %}
<h1>Top {{blocked}} defederated instances</h1>
+ {% elif reference %}
+ <h1>Top {{reference}} referencing instances</h1>
{% endif %}
<div class="scoreboard">
<table>
<th>№</th>
<th>Instance</th>
- <th>Defederations</th>
+ <th>{% if reference %}References{% else %}Blocks{% endif %}</th>
{% for entry in scores %}
<tr>
<td>{{loop.index}}</td>
<input type="submit" value="Submit" />
</form>
<p>
- <a href="./scoreboard?blockers=50">top 50 defederating</a> / <a href="./scoreboard?blocked=50">defederated instances</a>
+ <a href="./scoreboard?blockers=50">top 50 defederating</a> /
+ <a href="./scoreboard?blocked=50">defederated instances</a> /
+ <a href="./scoreboard?reference=50">referencing instances</a>
</p>
<div class="info">
known instances: {{info.known_instances}}<br/>