fix
This commit is contained in:
@@ -70,7 +70,7 @@ def get_towns():
|
||||
# ------------------------------------------------------------------
|
||||
# GET /dashboard/client-status
|
||||
# Returns whether the Tampermonkey client is considered online.
|
||||
# Online = at least one town_state row updated within the last 60 s.
|
||||
# Online = at least one town_state row updated within the last 150 s.
|
||||
# ------------------------------------------------------------------
|
||||
@dashboard.route('/dashboard/client-status', methods=['GET'])
|
||||
def client_status():
|
||||
@@ -85,7 +85,7 @@ def client_status():
|
||||
try:
|
||||
dt = datetime.fromisoformat(last_seen)
|
||||
age_s = (datetime.utcnow() - dt).total_seconds()
|
||||
online = age_s <= 60
|
||||
online = age_s <= 150
|
||||
except Exception:
|
||||
online = False
|
||||
else:
|
||||
@@ -132,7 +132,7 @@ def create_command():
|
||||
if cmd_type not in ('build', 'recruit'):
|
||||
return jsonify({'error': 'type must be build or recruit'}), 400
|
||||
|
||||
# Reject if the Tampermonkey client is offline (no state push in last 60 s)
|
||||
# Reject if the Tampermonkey client is offline (no state push in last 150 s)
|
||||
conn = get_db()
|
||||
row = conn.execute('SELECT MAX(updated_at) AS last_seen FROM town_state').fetchone()
|
||||
last_seen = row['last_seen'] if row else None
|
||||
@@ -140,7 +140,7 @@ def create_command():
|
||||
if last_seen:
|
||||
try:
|
||||
dt = datetime.fromisoformat(last_seen)
|
||||
client_online = (datetime.utcnow() - dt).total_seconds() <= 60
|
||||
client_online = (datetime.utcnow() - dt).total_seconds() <= 150
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user