}
@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")
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")
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:
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:
"blocked" : blocked,
"reference" : reference,
"software" : software,
- "originator": originator,
+ "command" : command,
"error_code": error_code,
"scores" : fba.json_from_response(response)
})