fba.cursor.execute("SELECT command, COUNT(domain) AS score FROM instances WHERE command IS NOT NULL GROUP BY command ORDER BY score DESC, command ASC LIMIT ?", [amount])
elif mode == "error_code":
fba.cursor.execute("SELECT last_status_code, COUNT(domain) AS score FROM instances WHERE last_status_code IS NOT NULL AND last_status_code != '200' GROUP BY last_status_code ORDER BY score DESC LIMIT ?", [amount])
+ elif mode == "avg_peers":
+ fba.cursor.execute("SELECT software, AVG(total_peers) AS sum FROM instances WHERE software IS NOT NULL GROUP BY software HAVING sum>0 ORDER BY sum DESC LIMIT ?", [amount])
else:
raise HTTPException(status_code=400, detail="No filter specified")
for domain, score in fba.cursor.fetchall():
scores.append({
"domain": domain,
- "score" : score
+ "score" : round(score)
})
return scores
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=command&amount={amount}")
elif mode == "error_code" and amount > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=error_code&amount={amount}")
+ elif mode == "avg_peers" and amount > 0:
+ response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=avg_peers&amount={amount}")
else:
raise HTTPException(status_code=400, detail="No filter specified")
sofware = tidyup.domain(software)
# DEBUG: print("DEBUG: sofware after tidyup.domain():", software)
- if software in ["akkoma", "rebased"]:
+ if software in ["akkoma", "rebased", "akkounfucked", "ched"]:
# DEBUG: print("DEBUG: Setting pleroma:", domain, software)
software = "pleroma"
elif software in ["hometown", "ecko"]:
# DEBUG: print("DEBUG: Setting mastodon:", domain, software)
software = "mastodon"
- elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey"]:
+ elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey", "magnetar", "keybump"]:
# DEBUG: print("DEBUG: Setting misskey:", domain, software)
software = "misskey"
elif software == "runtube.re":
<a href="{{base_url}}/scoreboard?mode=reference&amount=50">referencing instances</a> /
<a href="{{base_url}}/scoreboard?mode=software&amount=50">used software</a> /
<a href="{{base_url}}/scoreboard?mode=command&amount=10">commands</a> /
- <a href="{{base_url}}/scoreboard?mode=error_code&amount=30">error codes</a>
+ <a href="{{base_url}}/scoreboard?mode=error_code&amount=30">error codes</a> /
+ <a href="{{base_url}}/scoreboard?mode=avg_peers&amount=30">average peers</a>
</p>
{% endblock %}
{% block footer %}
{% extends "base.html" %}
-{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'command' %}TOP {{amount}} commands{% elif mode == 'error_code' %}TOP {{amount}} error codes{% elif mode == 'reference' %}TOP {{amount}} referencing instances{% elif mode == 'blocked' %}TOP {{amount}} deferated instances{% elif mode == 'blocker' %}TOP {{amount}} deferating instances{% endif %}{% endblock %}
+{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'avg_peers' %}TOP {{amount}} average peer count{% elif mode == 'command' %}TOP {{amount}} commands{% elif mode == 'error_code' %}TOP {{amount}} error codes{% elif mode == 'reference' %}TOP {{amount}} referencing instances{% elif mode == 'blocked' %}TOP {{amount}} deferated instances{% elif mode == 'blocker' %}TOP {{amount}} deferating instances{% endif %}{% endblock %}
{% block header %}
{% if mode == 'blocker' %}
<table>
<thead>
<th>№</th>
- <th>{% if mode == 'software' %}Software{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %}</th>
- <th>{% if mode == 'reference' %}References{% elif mode in('software', 'error_code') %}Total{% else %}Blocks{% endif %}</th>
+ <th>{% if mode in ('software', 'avg_peers') %}Software{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %}</th>
+ <th>{% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code') %}Total{% else %}Blocks{% endif %}</th>
</thead>
<tbody>
<tr>
<td>{{loop.index}}</td>
<td>
- {% if mode in ('software', 'command', 'error_code') %}
+ {% if mode in ('software', 'command', 'error_code', 'avg_peers') %}
{{entry['domain']}}
{% elif entry['domain'] == None %}
-