CHUNI: Add more chunithm frontend features

1. Implemented profile, rating and playlog webpages.
2. Fixed bugs of version change api and name change api.
This commit is contained in:
2024-04-15 01:35:27 +08:00
parent 36ab38b1ee
commit 976aa6b560
9 changed files with 853 additions and 59 deletions

View File

@ -757,3 +757,26 @@ class ChuniProfileData(BaseData):
return
return result.lastrowid
async def get_profile_rating(self, aime_id: int, version: int) -> Optional[List[Row]]:
sql = select(rating).where(and_(
rating.c.user == aime_id,
rating.c.version <= version,
))
result = await self.execute(sql)
if result is None:
self.logger.warning(f"Rating of user {aime_id}, version {version} was None")
return None
return result.fetchall()
async def get_all_profile_versions(self, aime_id: int) -> Optional[List[Row]]:
sql = select([profile.c.version]).where(profile.c.user == aime_id)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"user {aime_id}, has no profile")
return None
else:
versions_raw = result.fetchall()
versions = [row[0] for row in versions_raw]
return sorted(versions, reverse=True)