]> git.mxchange.org Git - fba.git/blobdiff - api.py
Continued:
[fba.git] / api.py
diff --git a/api.py b/api.py
index 8e95e58d7e6e3c58964993d175e47ab61235a734..5df098fdecbbc4d12ed1908fc227b880dbb4b963 100644 (file)
--- a/api.py
+++ b/api.py
@@ -24,7 +24,7 @@ def get_hash(domain: str) -> str:
 def info():
     conn = sqlite3.connect("blocks.db")
     c = conn.cursor()
-    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)")
+    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 = c.fetchone()
     c.close()
     return {
@@ -42,11 +42,11 @@ def top(blocked: int = None, blockers: int = None):
     elif blocked != None:
         if blocked > 500:
             raise HTTPException(status_code=400, detail="Too many results")
-        c.execute("SELECT blocked, count(blocked) FROM  blocks WHERE block_level = 'reject' group by blocked order by count(blocked) desc limit ?", (blocked,))
+        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")
-        c.execute("SELECT blocker, count(blocker) FROM  blocks WHERE block_level = 'reject' group by blocker order by count(blocker) desc limit ?", (blockers,))
+        c.execute("SELECT blocker, count(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY count(blocker) DESC LIMIT ?", (blockers,))
     scores = c.fetchall()
     c.close()
 
@@ -70,12 +70,12 @@ def blocked(domain: str = None, reason: str = None, reverse: str = None):
     if domain != None:
         wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
         punycode = domain.encode('idna').decode('utf-8')
-        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM  blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? order by first_added asc",
+        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_added asc",
                   (domain, "*." + domain, wildchar, get_hash(domain), punycode, "*." + punycode))
     elif reverse != None:
-        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM  blocks WHERE blocker = ? order by first_added asc", (reverse,))
+        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocker = ? ORDER BY first_added asc", (reverse,))
     else:
-        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM  blocks WHERE reason like ? AND reason != '' order by first_added asc", ("%"+reason+"%",))
+        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_added asc", ("%"+reason+"%",))
     blocks = c.fetchall()
     c.close()
 
@@ -163,10 +163,10 @@ def rss(request: Request, domain: str = None):
     if domain != None:
         wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
         punycode = domain.encode('idna').decode('utf-8')
-        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM  blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? order by first_added desc limit 50",
+        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_added DESC LIMIT 50",
                   (domain, "*." + domain, wildchar, get_hash(domain), punycode, "*." + punycode))
     else:
-        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM  blocks order by first_added desc limit 50")
+        c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks ORDER BY first_added DESC LIMIT 50")
     blocks = c.fetchall()
     c.close()