From: Roland Häder Date: Sat, 20 May 2023 11:31:29 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=21f1ec9ada1d7698a64393d07cd9570676d59934;p=fba.git Continued: - COUNT() is a SQL function, also always upper-case --- diff --git a/api.py b/api.py index 2f94925..bd1e376 100644 --- a/api.py +++ b/api.py @@ -14,7 +14,7 @@ templates = Jinja2Templates(directory=".") @app.get(fba.config["base_url"] + "/info") def info(): - fba.c.execute("SELECT (SELECT count(domain) FROM instances), (SELECT count(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica')), (SELECT count(blocker) FROM blocks)") + fba.c.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica')), (SELECT COUNT(blocker) FROM blocks)") known, indexed, blocks = fba.c.fetchone() return { @@ -31,11 +31,11 @@ def top(blocked: int = None, blockers: int = None): elif blocked != None: if blocked > 500: raise HTTPException(status_code=400, detail="Too many results") - fba.c.execute("SELECT blocked, count(blocked) FROM blocks WHERE block_level = 'reject' group by blocked ORDER BY count(blocked) DESC LIMIT ?", (blocked,)) + fba.c.execute("SELECT blocked, COUNT(blocked) FROM blocks WHERE block_level = 'reject' group by blocked ORDER BY COUNT(blocked) DESC LIMIT ?", (blocked,)) elif blockers != None: if blockers > 500: raise HTTPException(status_code=400, detail="Too many results") - fba.c.execute("SELECT blocker, count(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY count(blocker) DESC LIMIT ?", (blockers,)) + fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY COUNT(blocker) DESC LIMIT ?", (blockers,)) scores = fba.c.fetchall() scoreboard = []