mai2: add basic webui

This commit is contained in:
Kevin Trocolli
2024-06-09 03:05:57 -04:00
parent e7ddfcda2e
commit b4b8650acc
9 changed files with 813 additions and 2 deletions

View File

@@ -398,3 +398,23 @@ class Mai2ScoreData(BaseData):
if result is None:
return None
return result.fetchall()
async def get_playlogs(self, user_id: int, idx: int = 0, limit: int = 0) -> Optional[List[Row]]:
sql = playlog.select(playlog.c.user == user_id)
if limit:
sql = sql.limit(limit)
if idx:
sql = sql.offset(idx * limit)
result = await self.execute(sql)
if result:
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()