timestamp

This commit is contained in:
2026-05-02 02:36:48 +03:00
parent d8ba139d07
commit 83b8c85557

View File

@@ -369,10 +369,13 @@ def command_result(cmd_id):
# When an explicit farm_loot command succeeds, record the timestamp
if cmd and cmd['type'] == 'farm_loot' and status == 'done' and cmd['player_id']:
town_id = str(cmd['town_id'])
world_id = town_id.split('_')[1] if '_' in town_id else None
lf_key = f'last_farmed_{cmd["player_id"]}_{world_id}' if world_id else f'last_farmed_{cmd["player_id"]}'
conn.execute('''
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at
''', (f'last_farmed_{cmd["player_id"]}', now, now))
''', (lf_key, now, now))
conn.commit()
conn.close()
@@ -456,7 +459,7 @@ def farm_status():
conn.execute('''
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at
''', (f'last_farmed_{player_id}', now, now))
''', (f'last_farmed_{player_key}', now, now))
conn.commit()
conn.close()
return jsonify({'ok': True})