]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 21 Apr 2025 00:15:49 +0000 (02:15 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 21 Apr 2025 00:15:49 +0000 (02:15 +0200)
- no need to convert existing domain again, let's take row[domain] directly
- formatted SQL command

fba/commands.py

index 011cae1c0d1a3c5bbb26c4c9ba73cf569e622209..22eefbd2279e91da9ab6cd94f050eb8eb64c170d 100644 (file)
@@ -1078,31 +1078,35 @@ def fetch_instances(args: argparse.Namespace) -> int:
     database.cursor.execute(
         "SELECT domain, origin, software \
 FROM instances \
-WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'lemmy', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey', 'mammuthus', 'neodb', 'smithereen', 'vebinet', 'toki', 'snac', 'biblioreads', 'wordpress', 'oolong', 'diaspora', 'appy') \
+WHERE software IN ( \
+    'pleroma'   , 'mastodon', 'friendica' , 'misskey'  , 'lemmy'      , \
+    'peertube'  , 'takahe'  , 'gotosocial', 'brighteon', 'wildebeest' , \
+    'bookwyrm'  , 'mitra   ', 'areionskey', 'mammuthus', 'neodb'      , \
+    'smithereen', 'vebinet' , 'toki'      , 'snac'     , 'biblioreads', \
+    'wordpress' , 'oolong'  , 'diaspora'  , 'appy' \
+) \
 ORDER BY total_peers DESC, last_response_time ASC, last_updated ASC"
     )
 
     rows = database.cursor.fetchall()
     logger.info("Checking %d entries ...", len(rows))
     for row in rows:
-        logger.debug("row[domain]='%s' - BEFORE!", row["domain"])
-        domain = domain_helper.encode_idna(row["domain"])
-        logger.debug("domain='%s' - AFTER!", domain)
+        logger.debug("row[domain]='%s'", row["domain"])
 
-        if not domain_helper.is_wanted(domain):
-            logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
+        if not domain_helper.is_wanted(row["domain"]):
+            logger.warning("row[domain]='%s' is not wanted, you should execute remove_invalid for cleaning your database - SKIPPED!", row["domain"])
             continue
-        elif instances.is_recent(domain):
-            logger.debug("domain='%s' has recently been crawled - SKIPPED!")
+        elif instances.is_recent(row["domain"]):
+            logger.debug("row[domain]='%s' has recently been crawled - SKIPPED!", row["domain"])
             continue
 
         try:
-            logger.info("Fetching instances for domain='%s',origin='%s',software='%s' ...", domain, row["origin"], row["software"])
-            federation.fetch_instances(domain, row["origin"], row["software"], inspect.currentframe().f_code.co_name)
+            logger.info("Fetching instances for row[domain]='%s',origin='%s',software='%s' ...", row["domain"], row["origin"], row["software"])
+            federation.fetch_instances(row["domain"], row["origin"], row["software"], inspect.currentframe().f_code.co_name)
         except network.exceptions as exception:
-            logger.warning("Exception '%s' during fetching instances (fetch_instances) from domain='%s'", type(exception), domain)
-            instances.set_last_error(domain, exception)
-            instances.update(domain)
+            logger.warning("Exception '%s' during fetching instances (fetch_instances) from row[domain]='%s'", type(exception), row["domain"])
+            instances.set_last_error(row["domain"], exception)
+            instances.update(row["domain"])
 
     logger.debug("Success - EXIT!")
     return 0
@@ -1119,7 +1123,7 @@ def fetch_csv(args: argparse.Namespace) -> int:
 
         # Is domain given and not equal blocker?
         if isinstance(args.domain, str) and args.domain != block["blocker"]:
-            logger.debug("Skipping blocker='%s', not matching args.domain='%s'", block["blocker"], args.domain)
+            logger.debug("block[blocker]='%s' does not match args.domain='%s' - SKIPPED!", block["blocker"], args.domain)
             continue
 
         logger.debug("Invoking processing.csv_block(%s, %s, fetch_csv) ...", block["blocker"], block["csv_url"])