This commit is contained in:
2024-07-06 06:57:59 +07:00
parent 6f12f9988e
commit 5894831154
4 changed files with 64 additions and 53 deletions

View File

@ -176,7 +176,13 @@ class UserData(BaseData):
await self.execute(sql)
async def extend_lock_for_game(self, user_id: int, game: str):
sql = game_locks.update().where((game_locks.c.user == user_id) & (game_locks.c.game == game)).values(expires_at=func.date_add(func.now(), text("INTERVAL 15 MINUTE")))
async def extend_lock_for_game(self, user_id: int, game: str, extra: dict | None = None):
sql = (
insert(game_locks)
.values(user=user_id, game=game, extra=extra or {})
.on_duplicate_key_update(
expires_at=func.date_add(func.now(), text("INTERVAL 15 MINUTE")),
)
)
await self.execute(sql)