fix(user): fill with empty data in graph data to show correct graph

This commit is contained in:
MingxuanGame
2025-08-13 04:18:00 +00:00
parent 69e9927ea0
commit 29eb85bc4a
2 changed files with 12 additions and 0 deletions

View File

@@ -315,12 +315,22 @@ class UserResp(UserBase):
CountResp.from_db(pc)
for pc in await obj.awaitable_attrs.monthly_playcounts
]
if len(u.monthly_playcounts) == 1:
d = u.monthly_playcounts[0].start_date
u.monthly_playcounts.insert(
0, CountResp(start_date=d - timedelta(days=20), count=0)
)
if "replays_watched_counts" in include:
u.replay_watched_counts = [
CountResp.from_db(rwc)
for rwc in await obj.awaitable_attrs.replays_watched_counts
]
if len(u.replay_watched_counts) == 1:
d = u.replay_watched_counts[0].start_date
u.replay_watched_counts.insert(
0, CountResp(start_date=d - timedelta(days=20), count=0)
)
if "achievements" in include:
u.user_achievements = [

View File

@@ -74,5 +74,7 @@ class RankHistoryResp(BaseModel):
)
).all()
data = [result.rank for result in results]
if len(data) != 90:
data.extend([0] * (90 - len(data)))
data.reverse()
return cls(mode=mode, data=data)