]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 22 Jun 2023 22:46:40 +0000 (00:46 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 22 Jun 2023 22:47:23 +0000 (00:47 +0200)
- added metrics for blocking levels

api.py
templates/views/index.html
templates/views/scoreboard.html

diff --git a/api.py b/api.py
index 9217716f6e5e3a921e4985d29f59887a06b2a646..7ffa3c37bf91e951874428b12736acd3ee9d65c9 100644 (file)
--- a/api.py
+++ b/api.py
@@ -75,6 +75,8 @@ def api_scoreboard(mode: str, amount: int):
         database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obfuscation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount])
     elif mode == "obfuscation":
         database.cursor.execute("SELECT has_obfuscation, COUNT(domain) AS cnt FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica') GROUP BY has_obfuscation ORDER BY cnt DESC LIMIT ?", [amount])
+    elif mode == "block_level":
+        database.cursor.execute("SELECT block_level, COUNT(rowid) AS cnt FROM blocks GROUP BY block_level ORDER BY cnt DESC LIMIT ?", [amount])
     else:
         raise HTTPException(status_code=400, detail="No filter specified")
 
@@ -185,6 +187,8 @@ def scoreboard(request: Request, mode: str, amount: int):
         response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfuscator&amount={amount}")
     elif mode == "obfuscation" and amount > 0:
         response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfuscation&amount={amount}")
+    elif mode == "block_level" and amount > 0:
+        response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=block_level&amount={amount}")
     else:
         raise HTTPException(status_code=400, detail="No filter specified")
 
index 4c91f2beee09307fa32f74bf34f31e7598e9816c..a179703f1f78d84707e845927c059676780c7219 100644 (file)
@@ -33,7 +33,8 @@
         <a href="{{base_url}}/scoreboard?mode=error_code&amp;amount=30">error codes</a> /
         <a href="{{base_url}}/scoreboard?mode=avg_peers&amp;amount=30">average peers</a> /
         <a href="{{base_url}}/scoreboard?mode=obfuscator&amp;amount=30">obfuscating software</a> /
-        <a href="{{base_url}}/scoreboard?mode=obfuscation&amp;amount=10">obfuscation metrics</a>
+        <a href="{{base_url}}/scoreboard?mode=obfuscation&amp;amount=10">obfuscation metrics</a> /
+        <a href="{{base_url}}/scoreboard?mode=block_level&amp;amount=20">block level metrics</a>
     </p>
 {% endblock %}
 {% block footer %}
index 547a5ea8e83ac49a9f407f36d609ae6a9f6ccfd6..b4615e13dd3b2b0c488067984d6a184a527dce18 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 
-{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'obfuscation' %}obfuscation metrics{% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating 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 title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'block_level' %}TOP {{amount}} block level metrics{% elif mode == 'obfuscation' %}obfuscation metrics{% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating 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' %}
@@ -21,6 +21,8 @@
         <h1>TOP {{amount}} obfuscating software</h1>
     {% elif mode == 'obfuscation' %}
         <h1>obfuscation metrics</h1>
+    {% elif mode == 'block_level' %}
+        <h1>TOP {{amount}} block levels</h1>
     {% endif %}
 {% endblock %}
 
@@ -30,7 +32,7 @@
             <thead>
                 <th>№</th>
                 <th>{% if mode in ('software', 'avg_peers', 'obfuscator') %}Software{% elif mode == 'obfuscation' %}obfuscation status{% 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', 'obfuscator', 'obfuscation') %}Total{% else %}Blocks{% endif %}</th>
+                <th>{% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obfuscator', 'obfuscation', 'block_level') %}Total{% else %}Blocks{% endif %}</th>
             </thead>
 
             <tbody>
@@ -38,7 +40,7 @@
                 <tr>
                     <td>{{loop.index}}</td>
                     <td>
-                        {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfuscator', 'obfuscation') %}
+                        {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfuscator', 'obfuscation', 'block_level') %}
                             {{entry['domain']}}
                         {% elif entry['domain'] == None %}
                             -