fix(statistics): fix rank_history use country rank
This commit is contained in:
@@ -163,24 +163,25 @@ async def get_rank(
|
|||||||
if rank is None:
|
if rank is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
today = datetime.now(UTC).date()
|
if country is None:
|
||||||
rank_history = (
|
today = datetime.now(UTC).date()
|
||||||
await session.exec(
|
rank_history = (
|
||||||
select(RankHistory).where(
|
await session.exec(
|
||||||
RankHistory.user_id == statistics.user_id,
|
select(RankHistory).where(
|
||||||
RankHistory.mode == statistics.mode,
|
RankHistory.user_id == statistics.user_id,
|
||||||
RankHistory.date == today,
|
RankHistory.mode == statistics.mode,
|
||||||
|
RankHistory.date == today,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
).first()
|
||||||
).first()
|
if rank_history is None:
|
||||||
if rank_history is None:
|
rank_history = RankHistory(
|
||||||
rank_history = RankHistory(
|
user_id=statistics.user_id,
|
||||||
user_id=statistics.user_id,
|
mode=statistics.mode,
|
||||||
mode=statistics.mode,
|
date=today,
|
||||||
date=today,
|
rank=rank,
|
||||||
rank=rank,
|
)
|
||||||
)
|
session.add(rank_history)
|
||||||
session.add(rank_history)
|
else:
|
||||||
else:
|
rank_history.rank = rank
|
||||||
rank_history.rank = rank
|
|
||||||
return rank
|
return rank
|
||||||
|
|||||||
Reference in New Issue
Block a user