From 21f1ec9ada1d7698a64393d07cd9570676d59934 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 20 May 2023 13:31:29 +0200 Subject: [PATCH] Continued: - COUNT() is a SQL function, also always upper-case --- api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 = [] -- 2.39.5