]> git.mxchange.org Git - fba.git/blobdiff - api.py
Continued:
[fba.git] / api.py
diff --git a/api.py b/api.py
index 3add50d2be4b84c9745021b6f33126c25bdbd121..0fb839e41c46279f3055df74e3120650cdd0e5f5 100644 (file)
--- a/api.py
+++ b/api.py
@@ -47,7 +47,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, error_code: int = None):
+def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, command: int = None, error_code: int = None):
     if blocked is not None:
         if blocked > 500:
             raise HTTPException(status_code=400, detail="Too many results")
@@ -64,10 +64,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 is not None:
-        if originator > 500:
+    elif command is not None:
+        if command > 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])
+        fba.cursor.execute("SELECT command, COUNT(domain) FROM instances WHERE command IS NOT NULL GROUP BY command ORDER BY COUNT(domain) DESC, command ASC LIMIT ?", [command])
     elif error_code is not None:
         if error_code > 500:
             raise HTTPException(status_code=400, detail="Too many results")
@@ -154,7 +154,7 @@ def mutual(domains: list[str] = Query()):
     return JSONResponse(status_code=200, content={})
 
 @router.get(config.get("base_url") + "/scoreboard")
-def scoreboard(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, originator: int = None, error_code: int = None):
+def scoreboard(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, command: int = None, error_code: int = None):
     if blockers is not 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 is not None and blocked > 0:
@@ -163,8 +163,8 @@ def scoreboard(request: Request, blockers: int = None, blocked: int = None, refe
         response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?reference={reference}")
     elif software is not None and software > 0:
         response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?software={software}")
-    elif originator is not 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 command is not None and command > 0:
+        response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?command={command}")
     elif error_code is not 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:
@@ -184,7 +184,7 @@ def scoreboard(request: Request, blockers: int = None, blocked: int = None, refe
         "blocked"   : blocked,
         "reference" : reference,
         "software"  : software,
-        "originator": originator,
+        "command"   : command,
         "error_code": error_code,
         "scores"    : fba.json_from_response(response)
     })