Compare commits

..

4 Commits
1.2.3 ... 1.2.5

Author SHA1 Message Date
b8cf10b45d 🔖 1.2.5 2024-05-15 04:43:30 +08:00
4ec5c3bde1 🐛 修复 TETR.IO 大写用户名查询失败 2024-05-15 04:42:27 +08:00
270b953bc9 🔖 1.2.4 2024-05-15 04:22:58 +08:00
13bd0da592 🐛 修复去重添加没有正确工作的bug 2024-05-15 04:22:19 +08:00
3 changed files with 8 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
from asyncio import Lock
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from datetime import datetime, timezone
@@ -72,9 +73,11 @@ async def create_or_update_bind(
T = TypeVar('T', 'TETRIOHistoricalData', 'TOPHistoricalData', 'TOSHistoricalData')
lock = Lock()
async def anti_duplicate_add(cls: type[T], model: T) -> None:
async with get_session() as session:
async with lock, get_session() as session:
result = (
await session.scalars(
select(cls)
@@ -88,8 +91,8 @@ async def anti_duplicate_add(cls: type[T], model: T) -> None:
if i.data == model.data:
logger.debug('Anti duplicate successfully')
return
session.add(model)
await session.commit()
session.add(model)
await session.commit()
@asynccontextmanager

View File

@@ -43,7 +43,7 @@ class Player:
if self.user_id is not None:
return self.user_id
if self.user_name is not None:
return self.user_name
return self.user_name.lower()
msg = 'Invalid user'
raise ValueError(msg)

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = 'nonebot-plugin-tetris-stats'
version = '1.2.3'
version = '1.2.5'
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
authors = ['scdhh <wallfjjd@gmail.com>']
readme = 'README.md'