]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 3 Jun 2023 23:03:30 +0000 (01:03 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 3 Jun 2023 23:03:30 +0000 (01:03 +0200)
- exposed originator (Python script) Top "10"

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

diff --git a/api.py b/api.py
index 871398eec74c97131ee6fc12381a00c176b7415b..d89cf3f8ce9dfdecaf81150f74e358df2c91bbba 100644 (file)
--- a/api.py
+++ b/api.py
@@ -44,7 +44,7 @@ def info():
     }
 
 @router.get(fba.config["base_url"] + "/api/top.json", response_class=JSONResponse)
-def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None):
+def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, originator: int = None):
     if blocked != None:
         if blocked > 500:
             raise HTTPException(status_code=400, detail="Too many results")
@@ -61,6 +61,10 @@ def top(blocked: int = None, blockers: int = None, reference: int = None, softwa
         if software > 500:
             raise HTTPException(status_code=400, detail="Too many results")
         fba.cursor.execute("SELECT software, COUNT(domain) FROM instances WHERE software IS NOT NULL GROUP BY software ORDER BY COUNT(domain) DESC, software ASC LIMIT ?", [software])
+    elif originator != None:
+        if originator > 500:
+            raise HTTPException(status_code=400, detail="Too many results")
+        fba.cursor.execute("SELECT originator, COUNT(domain) FROM instances WHERE originator IS NOT NULL GROUP BY originator ORDER BY COUNT(domain) DESC, originator ASC LIMIT ?", [originator])
     else:
         raise HTTPException(status_code=400, detail="No filter specified")
 
@@ -139,7 +143,7 @@ def mutual(domains: list[str] = Query()):
     return JSONResponse(status_code=200, content={})
 
 @router.get(fba.config["base_url"] + "/scoreboard")
-def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None):
+def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, originator: int = None):
     scores = None
 
     if blockers != None and blockers > 0:
@@ -150,6 +154,8 @@ def index(request: Request, blockers: int = None, blocked: int = None, reference
         res = requests.get(f"http://{fba.config['host']}:{fba.config['port']}{fba.config['base_url']}/api/top.json?reference={reference}")
     elif software != None and software > 0:
         res = requests.get(f"http://{fba.config['host']}:{fba.config['port']}{fba.config['base_url']}/api/top.json?software={software}")
+    elif originator != None and originator > 0:
+        res = requests.get(f"http://{fba.config['host']}:{fba.config['port']}{fba.config['base_url']}/api/top.json?originator={originator}")
     else:
         raise HTTPException(status_code=400, detail="No filter specified")
 
@@ -167,6 +173,7 @@ def index(request: Request, blockers: int = None, blocked: int = None, reference
         "blocked"   : blocked,
         "reference" : reference,
         "software"  : software,
+        "originator": originator,
         "scores"    : res.json()
     })
 
index 39fcfcc977d197b5b9d5de0bbdeb032a88c0bbfe..857c820268d9d29a9d0996392267afc8fed59465 100644 (file)
             <a href="{{base_url}}/scoreboard?blockers=50">top 50 defederating</a> /
             <a href="{{base_url}}/scoreboard?blocked=50">defederated instances</a> /
             <a href="{{base_url}}/scoreboard?reference=50">referencing instances</a> /
-            <a href="{{base_url}}/scoreboard?software=50">used software</a>
+            <a href="{{base_url}}/scoreboard?software=50">used software</a> /
+            <a href="{{base_url}}/scoreboard?originator=10">originators</a>
         </p>
         <div class="info">
             known instances: {{info.known_instances}}<br/>
index 83e1f08541f0850eafbabf338a02b6dfa735943d..baacd00d317ede344409c69a6009ee97eb383897 100644 (file)
@@ -9,6 +9,9 @@
             text-align: center;
             font-family: sans;
         }
+        pre {
+            margin: 0px;
+        }
         .block_level {
             background-color: #1c1c3c;
             width: 80em;
                     <td>
                         {% if software %}
                             {{entry['domain']}}
+                        {% elif originator %}
+                            <pre>{{entry['domain']}}</pre>
                         {% else %}
                             <a href="{{base_url}}/?{% if blockers %}reverse{% elif blocked or reference %}domain{% endif %}={{entry['domain']}}" rel="nofollow noopener noreferrer">{{entry['domain']}}</a>&nbsp;
                             <a class="listlink" href="https://{{entry['domain']}}" rel="external" target="_blank">↗</a>
         </table>
     </div>
     <div class="info">
+        <a href="{{base_url}}/">Index</a> /
         source code: <a href="https://git.mxchange.org/?p=fba.git;a=summary" rel="source" target="_blank">git.mxchange.org</a><br /><br />
         {{slogan}}
     </div>