From: Roland Häder
Date: Thu, 8 Jun 2023 17:39:35 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c79881a2e2f8b39b0cd16a08713a145a97de1ed7;p=fba.git
Continued:
- added "TOP 30" of error codes (excluding 200)
---
diff --git a/api.py b/api.py
index 49a5c95..ec459f5 100644
--- a/api.py
+++ b/api.py
@@ -46,7 +46,7 @@ def info():
}
@router.get(config.get("base_url") + "/api/top.json", response_class=JSONResponse)
-def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, originator: int = None):
+def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, originator: int = None, error_code: int = None):
if blocked != None:
if blocked > 500:
raise HTTPException(status_code=400, detail="Too many results")
@@ -67,6 +67,10 @@ def top(blocked: int = None, blockers: int = None, reference: int = None, softwa
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])
+ elif error_code != None:
+ if error_code > 500:
+ raise HTTPException(status_code=400, detail="Too many results")
+ fba.cursor.execute("SELECT last_status_code, COUNT(domain) AS cnt FROM instances WHERE last_status_code IS NOT NULL AND last_status_code != '200' GROUP BY last_status_code ORDER BY cnt DESC LIMIT ?", [error_code])
else:
raise HTTPException(status_code=400, detail="No filter specified")
@@ -145,9 +149,7 @@ def mutual(domains: list[str] = Query()):
return JSONResponse(status_code=200, content={})
@router.get(config.get("base_url") + "/scoreboard")
-def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, originator: int = None):
- scores = None
-
+def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, originator: int = None, error_code: int = None):
if blockers != None and blockers > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?blockers={blockers}")
elif blocked != None and blocked > 0:
@@ -158,6 +160,8 @@ def index(request: Request, blockers: int = None, blocked: int = None, reference
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?software={software}")
elif originator != None and originator > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?originator={originator}")
+ elif error_code != None and error_code > 0:
+ response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?error_code={error_code}")
else:
raise HTTPException(status_code=400, detail="No filter specified")
@@ -176,6 +180,7 @@ def index(request: Request, blockers: int = None, blocked: int = None, reference
"reference" : reference,
"software" : software,
"originator": originator,
+ "error_code": error_code,
"scores" : fba.json_from_response(response)
})
diff --git a/templates/views/index.html b/templates/views/index.html
index 010ccd1..8a4db26 100644
--- a/templates/views/index.html
+++ b/templates/views/index.html
@@ -29,7 +29,8 @@
defederated instances /
referencing instances /
used software /
- originators
+ originators /
+ error codes
{% endblock %}
{% block footer %}
diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html
index de3453b..451cc43 100644
--- a/templates/views/scoreboard.html
+++ b/templates/views/scoreboard.html
@@ -21,8 +21,8 @@
â |
- {% if software %}Software{% else %}Instance{% endif %} |
- {% if reference %}References{% elif software %}Total{% else %}Blocks{% endif %} |
+ {% if software %}Software{% elif error_code %}Error code{% else %}Instance{% endif %} |
+ {% if reference %}References{% elif software or error_code %}Total{% else %}Blocks{% endif %} |
@@ -30,9 +30,7 @@
{{loop.index}} |
- {% if software %}
- {{entry['domain']}}
- {% elif originator %}
+ {% if software or originator or error_code %}
{{entry['domain']}}
{% elif entry['domain'] == None %}
-
|