From adff3848bd82c916089f8a3e3dea85edd39853ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Mon, 21 Apr 2025 15:45:43 +0800 Subject: [PATCH] Update nonebot_plugin_tetris_stats/games/tos/query.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../games/tos/query.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/nonebot_plugin_tetris_stats/games/tos/query.py b/nonebot_plugin_tetris_stats/games/tos/query.py index ac9a1ed..9e5382e 100644 --- a/nonebot_plugin_tetris_stats/games/tos/query.py +++ b/nonebot_plugin_tetris_stats/games/tos/query.py @@ -231,17 +231,18 @@ async def get_historical_data(unique_identifier: str) -> list[HistoryData]: .order_by(TOSHistoricalData.id.asc()) ) ).all() - extra_info = ( - await session.scalars( - select(TOSHistoricalData) - .where(TOSHistoricalData.id < user_infos[0].id) - .where(TOSHistoricalData.user_unique_identifier == unique_identifier) - .where(TOSHistoricalData.api_type == 'User Info') - .limit(1) - ) - ).one_or_none() - if extra_info is not None: - user_infos = [extra_info, *user_infos] + if user_infos: + extra_info = ( + await session.scalars( + select(TOSHistoricalData) + .where(TOSHistoricalData.id < user_infos[0].id) + .where(TOSHistoricalData.user_unique_identifier == unique_identifier) + .where(TOSHistoricalData.api_type == 'User Info') + .limit(1) + ) + ).one_or_none() + if extra_info is not None: + user_infos = [extra_info, *user_infos] return [ HistoryData(score=float(i.data.data.rating_now), record_at=i.update_time.astimezone(ZoneInfo('Asia/Shanghai'))) for i in user_infos