timestamp
This commit is contained in:
@@ -369,10 +369,13 @@ def command_result(cmd_id):
|
|||||||
|
|
||||||
# When an explicit farm_loot command succeeds, record the timestamp
|
# When an explicit farm_loot command succeeds, record the timestamp
|
||||||
if cmd and cmd['type'] == 'farm_loot' and status == 'done' and cmd['player_id']:
|
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('''
|
conn.execute('''
|
||||||
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
|
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
|
||||||
ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at
|
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.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
@@ -456,7 +459,7 @@ def farm_status():
|
|||||||
conn.execute('''
|
conn.execute('''
|
||||||
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
|
INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?)
|
||||||
ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at
|
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.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return jsonify({'ok': True})
|
return jsonify({'ok': True})
|
||||||
|
|||||||
Reference in New Issue
Block a user