From 0b5de8aec060252079ba327cda0c4ea3b922e039 Mon Sep 17 00:00:00 2001 From: ssttkkl Date: Sat, 9 Sep 2023 01:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=8B=E5=8A=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEPT=E8=AE=B0=E5=BD=95=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/mapper/season_user_point_csv_mapper.py | 2 +- src/nonebot_plugin_mahjong_scoreboard/repository/season.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nonebot_plugin_mahjong_scoreboard/controller/mapper/season_user_point_csv_mapper.py b/src/nonebot_plugin_mahjong_scoreboard/controller/mapper/season_user_point_csv_mapper.py index 5e8b192..efd9f9f 100644 --- a/src/nonebot_plugin_mahjong_scoreboard/controller/mapper/season_user_point_csv_mapper.py +++ b/src/nonebot_plugin_mahjong_scoreboard/controller/mapper/season_user_point_csv_mapper.py @@ -27,7 +27,7 @@ async def write_season_user_point_change_logs_csv(f: TextIO, logs: Iterable[Seas scale = season.config.point_precision # 初步绘制表格 - for log in logs: + for log in sorted(logs, key=lambda l: l.create_time): if log.user.id not in user_idx: table.append([f"{await get_user_nickname(bot, log.user.platform_user_id, season.group.platform_group_id)}" f" ({log.user.platform_user_id.real_id})", ""]) diff --git a/src/nonebot_plugin_mahjong_scoreboard/repository/season.py b/src/nonebot_plugin_mahjong_scoreboard/repository/season.py index 770e918..b18dc42 100644 --- a/src/nonebot_plugin_mahjong_scoreboard/repository/season.py +++ b/src/nonebot_plugin_mahjong_scoreboard/repository/season.py @@ -90,6 +90,8 @@ async def get_season_user_point_change_logs(self, season_id: Optional[int] = Non if user_id is not None: stmt = stmt.where(SeasonUserPointChangeLogOrm.user_id == user_id) + stmt.order_by(SeasonUserPointChangeLogOrm.create_time) + result = (await self.session.execute(stmt)).all() data = [row[0] for row in result] return data @@ -98,9 +100,10 @@ async def change_season_user_point_manually(self, season_id: int, user_id: int, point: float) -> SeasonUserPointOrm: season = await self.get_by_pk(season_id) - sup = await self.get_season_user_point(season_id, user_id, insert_on_missing=True) + point = int(point * (10 ** -season.config.point_precision)) - sup.point = int(point * (10 ** -season.config.point_precision)) + sup = await self.get_season_user_point(season_id, user_id, insert_on_missing=True) + sup.point = point log = SeasonUserPointChangeLogOrm(season_id=season.id, user_id=user_id, change_type=SeasonUserPointChangeType.manually,