# DEBUG: print("DEBUG: EXIT!")
+def update_last_instance_fetch(domain: str):
+ #print("DEBUG: Updating last_instance_fetch for domain:", domain)
+ try:
+ cursor.execute("UPDATE instances SET last_instance_fetch = ?, last_updated = ? WHERE domain = ? LIMIT 1", [
+ time.time(),
+ time.time(),
+ domain
+ ])
+
+ if cursor.rowcount == 0:
+ print("WARNING: Did not update any rows:", domain)
+
+ except BaseException as e:
+ print(f"ERROR: failed SQL query: domain='{domain}',exception:'{str(e)}'")
+ sys.exit(255)
+
+ connection.commit()
+ #print("DEBUG: EXIT!")
+
def update_last_nodeinfo(domain: str):
# DEBUG: print("DEBUG: Updating last_nodeinfo for domain:", domain)
try:
# DEBUG: print(f"DEBUG: Adding peer: '{row['host']}'")
peers.append(row["host"])
+ update_last_instance_fetch(domain)
+
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
elif software == "lemmy":
except BaseException as e:
print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{str(e)}'")
- update_last_nodeinfo(domain)
+ update_last_instance_fetch(domain)
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
except BaseException as e:
print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{str(e)}'")
- update_last_nodeinfo(domain)
+ update_last_instance_fetch(domain)
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
print("WARNING: Some error during get():", domain, e)
update_last_error(domain, e)
- update_last_nodeinfo(domain)
+ update_last_instance_fetch(domain)
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
# Loop through some instances
fba.cursor.execute(
- "SELECT domain,origin,software FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe', 'lemmy') AND (last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]]
+ "SELECT domain,origin,software FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe', 'lemmy') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]]
)
rows = fba.cursor.fetchall()