Skip to content

Commit

Permalink
修复手动设置PT记录不正确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttkkl committed Sep 8, 2023
1 parent 3222d69 commit 0b5de8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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})", ""])
Expand Down
7 changes: 5 additions & 2 deletions src/nonebot_plugin_mahjong_scoreboard/repository/season.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 0b5de8a

Please sign in to comment.