mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-14 03:37:29 +08:00
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:
@@ -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)
|
||||
@@ -190,6 +190,23 @@ class ChuniScoreData(BaseData):
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def get_playlogs_limited(self, aime_id: int, index: int, count: int) -> Optional[Row]:
|
||||
sql = select(playlog).where(playlog.c.user == aime_id).order_by(playlog.c.id.desc()).limit(count).offset(index * count)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(f" aime_id {aime_id} has no playlog ")
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def get_user_playlogs_count(self, aime_id: int) -> Optional[Row]:
|
||||
sql = select(func.count()).where(playlog.c.user == aime_id)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(f" aime_id {aime_id} has no playlog ")
|
||||
return None
|
||||
return result.scalar()
|
||||
|
||||
async def put_playlog(self, aime_id: int, playlog_data: Dict, version: int) -> Optional[int]:
|
||||
# Calculate the ROM version that should be inserted into the DB, based on the version of the ggame being inserted
|
||||
# We only need from Version 10 (Plost) and back, as newer versions include romVersion in their upsert
|
||||
|
||||
Reference in New Issue
Block a user