From 7f86b5f3e3a0e1a7948c1664f929ad2cf2113359 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 24 Aug 2023 07:31:25 +0200 Subject: [PATCH] Continued: - sorted domains for fetch_blocks after how many total blocks have already been found --- fba/commands.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 15ef6bd..b35940d 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -283,24 +283,24 @@ def fetch_blocks(args: argparse.Namespace) -> int: # Re-check single domain logger.debug("Querying database for args.domain='%s' ...", args.domain) database.cursor.execute( - "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE domain = ?", [args.domain] + "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE domain = ? LIMIT 1", [args.domain] ) elif args.software is not None and args.software != "": # Re-check single software logger.debug("Querying database for args.software='%s' ...", args.software) database.cursor.execute( - "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? AND nodeinfo_url IS NOT NULL", [args.software] + "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? AND nodeinfo_url IS NOT NULL ORDER BY total_blocks DESC", [args.software] ) elif args.force: # Re-check all logger.debug("Re-checking all instances ...") database.cursor.execute( - "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey') AND nodeinfo_url IS NOT NULL ORDER BY rowid DESC" + "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey') AND nodeinfo_url IS NOT NULL ORDER BY total_blocks DESC" ) else: # Re-check after "timeout" (aka. minimum interval) database.cursor.execute( - "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey') AND (last_blocked IS NULL OR last_blocked < ?) AND nodeinfo_url IS NOT NULL ORDER BY rowid DESC", [time.time() - config.get("recheck_block")] + "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey') AND (last_blocked IS NULL OR last_blocked < ?) AND nodeinfo_url IS NOT NULL ORDER BY total_blocks DESC", [time.time() - config.get("recheck_block")] ) rows = database.cursor.fetchall() -- 2.39.5