@app.get(fba.config["base_url"] + "/info")
def info():
- fba.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica', 'bookwyrm', 'takahe')), (SELECT COUNT(blocker) FROM blocks)")
- known, indexed, blocks = fba.cursor.fetchone()
+ fba.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica', 'bookwyrm', 'takahe')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_status_code IS NOT NULL)")
+ known, indexed, blocks, errorous = fba.cursor.fetchone()
return {
- "known_instances" : known,
- "indexed_instances": indexed,
- "blocks_recorded" : blocks,
- "slogan" : fba.config["slogan"]
+ "known_instances" : known,
+ "indexed_instances" : indexed,
+ "blocks_recorded" : blocks,
+ "errorous_instances": errorous,
+ "slogan" : fba.config["slogan"]
}
@app.get(fba.config["base_url"] + "/top")
def update_last_error(domain: str, res: any):
# NOISY-DEBUG: print("DEBUG: domain,res.status_code:", domain, res.status_code, res.reason)
try:
+ # NOISY-DEBUG: print("DEBUG: res[]:", type(res))
+ if isinstance(res, BaseException):
+ res = str(res)
+
if type(res) is str:
cursor.execute("UPDATE instances SET last_status_code = 999, last_error_details = ?, last_updated = ? WHERE domain = ?", [
res,
update_last_error(domain, res)
continue
- except:
+ except BaseException as e:
# NOISY-DEBUG: print("DEBUG: Cannot fetch API request:", request)
+ update_last_error(domain, e)
pass
# NOISY-DEBUG: print("DEBUG: json[]:", type(json))
if json is None or len(json) == 0:
print("WARNING: Failed fetching nodeinfo from domain:", domain)
- update_last_error(domain, "Cannot fetch nodeinfo")
# NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
return json
else:
print("WARNING: nodeinfo does not contain 'links':", domain)
- except:
+ except BaseException as e:
print("WARNING: Failed fetching .well-known info:", domain)
- update_last_error(domain, "Cannot fetch .well-known")
+ update_last_error(domain, e)
pass
# NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
)
if domain in pending_errors:
- print("DEBUG: domain has pending error be updated:", domain)
+ # NOISY-DEBUG: print("DEBUG: domain has pending error be updated:", domain)
update_last_error(domain, pending_errors[domain])
del pending_errors[domain]