From: Roland Häder Date: Sat, 20 May 2023 08:33:34 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d63d2c3023f45e254a3b1efa22dd92ef0b8e148b;p=fba.git Continued: - be kind! set recheck_instance to at least 3600 seconds (one hour) --- diff --git a/config.defaults.json b/config.defaults.json index 1a0b4df..3578f7d 100644 --- a/config.defaults.json +++ b/config.defaults.json @@ -7,5 +7,6 @@ "bot_instance": "https://example.com", "bot_token": "", "bot_visibility": "unlisted", - "slogan": "### Your footer slogan ###" + "slogan": "### Your footer slogan ###", + "recheck_instance": 3600 } diff --git a/fba.py b/fba.py index c78dd64..fded8ec 100644 --- a/fba.py +++ b/fba.py @@ -204,12 +204,11 @@ def add_instance(domain: str): print("--- Adding new instance:", domain) try: c.execute( - "INSERT INTO instances SELECT ?, ?, ?, ?", + "INSERT INTO instances SELECT ?, ?, ?, NULL", ( domain, get_hash(domain), - determine_software(domain), - time.time() + determine_software(domain) ), ) diff --git a/fetch_instances.py b/fetch_instances.py index f9e3836..3797bd3 100644 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -1,6 +1,7 @@ import sqlite3 import sys import json +import time import fba def fetch_instances(domain: str): @@ -49,7 +50,7 @@ fetch_instances(instance) # Loop through some instances fba.c.execute( - "SELECT domain FROM instances WHERE software IS NOT NULL ORDER BY rowid DESC" + "SELECT domain FROM instances WHERE software IS NOT NULL AND (last_access IS NULL OR last_access < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]] ) for instance in fba.c.fetchall():